mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 19:26:42 +08:00
Merge pull request #3988 from NativeScript/fix-autocapitalization-type
FIX: Crash when setting autocapitalizationType=allCharacters in xml
This commit is contained in:
@ -38,7 +38,7 @@ editableProperty.register(EditableTextBase);
|
|||||||
export const updateTextTriggerProperty = new Property<EditableTextBase, UpdateTextTrigger>({ name: "updateTextTrigger", defaultValue: "textChanged" });
|
export const updateTextTriggerProperty = new Property<EditableTextBase, UpdateTextTrigger>({ name: "updateTextTrigger", defaultValue: "textChanged" });
|
||||||
updateTextTriggerProperty.register(EditableTextBase);
|
updateTextTriggerProperty.register(EditableTextBase);
|
||||||
|
|
||||||
const autocapitalizationTypeConverter = makeParser<AutocapitalizationType>(makeValidator<AutocapitalizationType>("none", "words", "sentences", "allCharacters"));
|
const autocapitalizationTypeConverter = makeParser<AutocapitalizationType>(makeValidator<AutocapitalizationType>("none", "words", "sentences", "allcharacters"));
|
||||||
|
|
||||||
export const autocapitalizationTypeProperty = new Property<EditableTextBase, AutocapitalizationType>({ name: "autocapitalizationType", defaultValue: "sentences", valueConverter: autocapitalizationTypeConverter });
|
export const autocapitalizationTypeProperty = new Property<EditableTextBase, AutocapitalizationType>({ name: "autocapitalizationType", defaultValue: "sentences", valueConverter: autocapitalizationTypeConverter });
|
||||||
autocapitalizationTypeProperty.register(EditableTextBase);
|
autocapitalizationTypeProperty.register(EditableTextBase);
|
||||||
|
@ -321,14 +321,14 @@ export abstract class EditableTextBase extends EditableTextBaseCommon {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[autocapitalizationTypeProperty.getDefault](): "none" | "words" | "sentences" | "allCharacters" | string {
|
[autocapitalizationTypeProperty.getDefault](): "none" | "words" | "sentences" | "allcharacters" | string {
|
||||||
let inputType = this.nativeView.getInputType();
|
let inputType = this.nativeView.getInputType();
|
||||||
if ((inputType & android.text.InputType.TYPE_TEXT_FLAG_CAP_WORDS) === android.text.InputType.TYPE_TEXT_FLAG_CAP_WORDS) {
|
if ((inputType & android.text.InputType.TYPE_TEXT_FLAG_CAP_WORDS) === android.text.InputType.TYPE_TEXT_FLAG_CAP_WORDS) {
|
||||||
return "words";
|
return "words";
|
||||||
} else if ((inputType & android.text.InputType.TYPE_TEXT_FLAG_CAP_SENTENCES) === android.text.InputType.TYPE_TEXT_FLAG_CAP_SENTENCES) {
|
} else if ((inputType & android.text.InputType.TYPE_TEXT_FLAG_CAP_SENTENCES) === android.text.InputType.TYPE_TEXT_FLAG_CAP_SENTENCES) {
|
||||||
return "sentences";
|
return "sentences";
|
||||||
} else if ((inputType & android.text.InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS) === android.text.InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS) {
|
} else if ((inputType & android.text.InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS) === android.text.InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS) {
|
||||||
return "allCharacters";
|
return "allcharacters";
|
||||||
} else {
|
} else {
|
||||||
return inputType.toString();
|
return inputType.toString();
|
||||||
}
|
}
|
||||||
@ -347,7 +347,7 @@ export abstract class EditableTextBase extends EditableTextBaseCommon {
|
|||||||
case "sentences":
|
case "sentences":
|
||||||
inputType = inputType | android.text.InputType.TYPE_TEXT_FLAG_CAP_SENTENCES; //16384(0x00040000) 15th bit
|
inputType = inputType | android.text.InputType.TYPE_TEXT_FLAG_CAP_SENTENCES; //16384(0x00040000) 15th bit
|
||||||
break;
|
break;
|
||||||
case "allCharacters":
|
case "allcharacters":
|
||||||
inputType = inputType | android.text.InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS; //4096 (0x00010000) 13th bit
|
inputType = inputType | android.text.InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS; //4096 (0x00010000) 13th bit
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -48,7 +48,7 @@ export class EditableTextBase extends TextBase {
|
|||||||
export type KeyboardType = "datetime" | "phone" | "number" | "url" | "email";
|
export type KeyboardType = "datetime" | "phone" | "number" | "url" | "email";
|
||||||
export type ReturnKeyType = "done" | "next" | "go" | "search" | "send";
|
export type ReturnKeyType = "done" | "next" | "go" | "search" | "send";
|
||||||
export type UpdateTextTrigger = "focusLost" | "textChanged";
|
export type UpdateTextTrigger = "focusLost" | "textChanged";
|
||||||
export type AutocapitalizationType = "none" | "words" | "sentences" | "allCharacters";
|
export type AutocapitalizationType = "none" | "words" | "sentences" | "allcharacters";
|
||||||
|
|
||||||
export const keyboardTypeProperty: Property<EditableTextBase, KeyboardType>;
|
export const keyboardTypeProperty: Property<EditableTextBase, KeyboardType>;
|
||||||
export const returnKeyTypeProperty: Property<EditableTextBase, ReturnKeyType>;
|
export const returnKeyTypeProperty: Property<EditableTextBase, ReturnKeyType>;
|
||||||
|
@ -120,7 +120,7 @@ export abstract class EditableTextBase extends EditableTextBaseCommon {
|
|||||||
this.nativeView.returnKeyType = newValue;
|
this.nativeView.returnKeyType = newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
[autocapitalizationTypeProperty.getDefault](): "none" | "words" | "sentences" | "allCharacters" {
|
[autocapitalizationTypeProperty.getDefault](): "none" | "words" | "sentences" | "allcharacters" {
|
||||||
let autocapitalizationType = this.nativeView.autocapitalizationType;
|
let autocapitalizationType = this.nativeView.autocapitalizationType;
|
||||||
switch (autocapitalizationType) {
|
switch (autocapitalizationType) {
|
||||||
case UITextAutocapitalizationType.None:
|
case UITextAutocapitalizationType.None:
|
||||||
@ -133,13 +133,13 @@ export abstract class EditableTextBase extends EditableTextBaseCommon {
|
|||||||
return "sentences";
|
return "sentences";
|
||||||
|
|
||||||
case UITextAutocapitalizationType.AllCharacters:
|
case UITextAutocapitalizationType.AllCharacters:
|
||||||
return "allCharacters";
|
return "allcharacters";
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new Error("Invalid autocapitalizationType value:" + autocapitalizationType);
|
throw new Error("Invalid autocapitalizationType value:" + autocapitalizationType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
[autocapitalizationTypeProperty.setNative](value: "none" | "words" | "sentences" | "allCharacters") {
|
[autocapitalizationTypeProperty.setNative](value: "none" | "words" | "sentences" | "allcharacters") {
|
||||||
let newValue: UITextAutocapitalizationType;
|
let newValue: UITextAutocapitalizationType;
|
||||||
switch (value) {
|
switch (value) {
|
||||||
case "none":
|
case "none":
|
||||||
@ -151,7 +151,7 @@ export abstract class EditableTextBase extends EditableTextBaseCommon {
|
|||||||
case "sentences":
|
case "sentences":
|
||||||
newValue = UITextAutocapitalizationType.Sentences;
|
newValue = UITextAutocapitalizationType.Sentences;
|
||||||
break;
|
break;
|
||||||
case "allCharacters":
|
case "allcharacters":
|
||||||
newValue = UITextAutocapitalizationType.AllCharacters;
|
newValue = UITextAutocapitalizationType.AllCharacters;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -108,7 +108,7 @@ export module AutocapitalizationType {
|
|||||||
export var none: string = "none";
|
export var none: string = "none";
|
||||||
export var words: string = "words";
|
export var words: string = "words";
|
||||||
export var sentences: string = "sentences";
|
export var sentences: string = "sentences";
|
||||||
export var allCharacters: string = "allCharacters";
|
export var allCharacters: string = "allcharacters";
|
||||||
}
|
}
|
||||||
|
|
||||||
export module NavigationBarVisibility {
|
export module NavigationBarVisibility {
|
||||||
|
Reference in New Issue
Block a user