Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Enhancement] AutoCaptialization support for Entry/Editor #1683

Closed
hartez opened this issue Jan 26, 2018 · 6 comments · Fixed by #1833 or #2116
Closed

[Enhancement] AutoCaptialization support for Entry/Editor #1683

hartez opened this issue Jan 26, 2018 · 6 comments · Fixed by #1833 or #2116

Comments

@hartez
Copy link
Contributor

hartez commented Jan 26, 2018

Rationale

The Entry and Editor Keyboard flags do not represent all the possible platform options for Input Capitalization

Implementation

Expand Keyboard flags to include Word, Character, and No Capitalized. The keyboard already supports CapitalizeSentence so it just needs to have Words and Characters added to it

Currently

[Flags]
	public enum KeyboardFlags
	{
		None = 0,
		CapitalizeSentence = 1,
		Spellcheck = 1 << 1,
		Suggestions = 1 << 2,
		All = ~0
	}

Expand To

[Flags]
	public enum KeyboardFlags
	{
		None = 0,
		CapitalizeSentence = 1,
		Spellcheck = 1 << 1,
		Suggestions = 1 << 2,
		CapitalizeWords = 1 << 3,
		CapitalizeCharacters = 1 << 4,
		CapitalizeNone = 1 << 5,
		All = ~0
	}

Currently None only really has in meaning for iOS

iOS

Add checks for additional flags to

public static void ApplyKeyboard(this IUITextInput textInput, Keyboard keyboard)

To set the keyboard settings for iOS

These settings are mutually exclusive so if the user specifies multiple they'll just get one and warning

Android

Add checks for additional flags to

public static InputTypes ToInputType(this Keyboard self)

There are currently checks inside this method that verifies valid permutations and warns the user if the settings don't make sense together. The new flags should be figured into these warnings

UWP

Currently UWP completely lacks any custom keyboard implementation

public static InputScope ToInputScope(this Keyboard self)

The WPF implementation has CustomKeyboard settings that mostly all just end up as setting the InputScopeName to Default but it comes with a set of warnings based on non compatible settings which I feel has value
https://msdn.microsoft.com/en-us/library/windows/apps/mt280229.aspx?f=255&MSPPError=-2147217396

Default behavior won't change but user will now get a warning

Backward Compatibility

The user will see some additional warnings if they setup an invalid configuration on UWP but the behavior will be the same,. If the user set ALL it would default to Sentence before so just make sure that it still defaults to Sentence if multiple values are set

Difficulty: Easy

@hartez
Copy link
Contributor Author

hartez commented Jan 26, 2018

This is dependent on #1652.

@hartez hartez changed the title [Enhancement] AutoCaptializtion support for Entry/Editor [Enhancement] AutoCaptialization support for Entry/Editor Jan 26, 2018
@PureWeen PureWeen self-assigned this Feb 5, 2018
@PureWeen
Copy link
Contributor

PureWeen commented Feb 6, 2018

Some UWP observations

  • UWP has a concept of Sentence Capitalization but it's enabled indirectly various permutations of input scope (https://docs.microsoft.com/en-us/windows/uwp/design/input/use-input-scope-to-change-the-touch-keyboard) or by setting IsSpellCheckEnabled. But we most likely can't depend on that property as it conflicts with
    [Enhancement] IsSpellCheckEnabled on Entry/Editor #1660.

  • The idea of Input Scopes affecting what you type seems to isolated to touch interfaces. If you're just using an attached keyboard or the onboard keyboard then input scopes are ignored

  • NameOrPhoneNumber input scope does word Capitalization but we probably don't want to rely on input scopes for this behavior

  • As far as custom implementations the one problem with custom implementations is that they capitalize the word after typing whereas with input scopes and on ios/android they set the intention of the keyboard before typing so the user can "opt out" and I haven't seen a valid way to emulate this behavior inside UWP

  • iOS/Android auto add a period after hitting the space bar twice. Is that something we want to emulate when the capitalization mode is Sentence?

  • AutocapitalizationType on UWP is also much more opinionated then iOS/Android in that you're totally stuck with all caps or all lower

A react native windows issue noting same behaviors
microsoft/react-native-windows#801

I have an implementation of after you type capitalization for words/sentences built but just need to make sure, confirm, and discuss how all this plays with InputScopes on UWP

@hartez
Copy link
Contributor Author

hartez commented Feb 6, 2018

iOS/Android auto add a period after hitting the space bar twice. Is that something we want to emulate when the capitalization mode is Sentence?

On Windows that's a system setting (under Typing). So I think we let the OS handle that.

@hartez
Copy link
Contributor Author

hartez commented Feb 6, 2018

It looks like auto-capitalization of sentences is also a system setting for Windows 10. So I think instead of emulating it (which might conflict with the system setting), we should just ignore that value on UWP and log a warning (Xamarin.Forms.Internals.Log) if we're in Debug mode saying something like "this value has no effect on this OS".

And then we document the heck out of that.

@PureWeen
Copy link
Contributor

PureWeen commented Feb 8, 2018

Initial spec/implementation used an enum

 public enum AutoCapitalization
    {
		Default = 0,
		None = 1,
		Words = 2,
		Sentences = 3,
		Characters = 4
	}

After implementing it with the above enum I realized that this didn't quite capture the intent. Using this enum comes across as a text transformation instead of affecting the keyboard. Plus we already have a Keyboard flag for Sentences so using the enum above would have made this configurable in two different places.

jsuarezruiz added a commit to XamarinFormsCommunity/Xamarin.Forms that referenced this issue Feb 28, 2018
* 'master' of https://github.com/xamarin/Xamarin.Forms: (23 commits)
  [C] use direct cast
  [Core, iOS, Android, UWP, WPF] Hide scroll view scroll bars (xamarin#1910)
  Allow users to specify resolution method for handlers, effects, and services (xamarin#1870) fixes xamarin#1739
  [Build] Update submodule
  Capitalization keyboard flag additions for Entry/Editor (xamarin#1683) (xamarin#1833)
  [Build] Don't specify .net sdk version
  Simplify event raising invocation pattern (xamarin#1971)
  [iOS Maps] Pin rendering customization (xamarin#1065)
  set csharp_space_after_keywords_in_control_flow_statements to true to fit our design guide lines (xamarin#1964)
  [iOS] Add shadow effect (xamarin#1896)
  Added support for ListView full width separators on iOS (xamarin#1854) fixes xamarin#1665
  Support CascadeInputTransparent to Tizen (xamarin#1916)
  [Android]?Remove UserVisibleHint (xamarin#1550) fixes xamarin#1438
  [iOS] ViewDidLayoutSubviews after removing page (xamarin#1532) fixes xamarin#1426
  Use relative URL to support recursive checkout in VSTS (xamarin#1926)
  [UITest] Fix test for UITest package update (xamarin#1923)
  Implemented MaxLength property on Entry and Editor (xamarin#1880)
  [Build]Fix master and build (xamarin#1920)
  [Build] Fix windows cert
  Fix to absolute URL
  ...

# Conflicts:
#	Xamarin.Forms.Controls/CoreGalleryPages/EditorCoreGalleryPage.cs
#	Xamarin.Forms.Controls/CoreGalleryPages/EntryCoreGalleryPage.cs
#	Xamarin.Forms.Core/InputView.cs
#	Xamarin.Forms.CustomAttributes/TestAttributes.cs
#	Xamarin.Forms.Platform.Android/Renderers/EditorRenderer.cs
#	Xamarin.Forms.Platform.Android/Renderers/EntryRenderer.cs
#	Xamarin.Forms.Platform.MacOS/Renderers/EditorRenderer.cs
#	Xamarin.Forms.Platform.MacOS/Renderers/EntryRenderer.cs
#	Xamarin.Forms.Platform.Tizen/Renderers/EditorRenderer.cs
#	Xamarin.Forms.Platform.Tizen/Renderers/EntryRenderer.cs
#	Xamarin.Forms.Platform.WPF/Renderers/EditorRenderer.cs
#	Xamarin.Forms.Platform.WPF/Renderers/EntryRenderer.cs
#	Xamarin.Forms.Platform.iOS/Renderers/EditorRenderer.cs
#	Xamarin.Forms.Platform.iOS/Renderers/EntryRenderer.cs
@titoleru
Copy link

This should be reopened, since there is still no cross platform solution autocapitalization in Entries & Editors

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.