Skip to content

Commit f0b1a83

Browse files
authored
fix crash with samsung keyboard when using password textboxes (#18793)
1 parent 808c86f commit f0b1a83

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/Android/Avalonia.Android/Platform/Input/AvaloniaInputConnection.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,20 +279,20 @@ public CapitalizationMode GetCursorCapsMode([GeneratedEnum] CapitalizationMode r
279279

280280
public ICharSequence? GetSelectedTextFormatted([GeneratedEnum] GetTextFlags flags)
281281
{
282-
return new SpannableString(_editBuffer.SelectedText);
282+
return new Java.Lang.String(_editBuffer.SelectedText ?? "");
283283
}
284284

285285
public ICharSequence? GetTextAfterCursorFormatted(int n, [GeneratedEnum] GetTextFlags flags)
286286
{
287287
var end = Math.Min(_editBuffer.Selection.End, _editBuffer.Text.Length);
288-
return new SpannableString(_editBuffer.Text.Substring(end, Math.Min(n, _editBuffer.Text.Length - end)));
288+
return new Java.Lang.String(_editBuffer.Text.Substring(end, Math.Min(n, _editBuffer.Text.Length - end)));
289289
}
290290

291291
public ICharSequence? GetTextBeforeCursorFormatted(int n, [GeneratedEnum] GetTextFlags flags)
292292
{
293293
var start = Math.Max(0, _editBuffer.Selection.Start - n);
294294
var length = _editBuffer.Selection.Start - start;
295-
return _editBuffer.Text == null ? null : new SpannableString(_editBuffer.Text.Substring(start, length));
295+
return _editBuffer.Text == null ? null : new Java.Lang.String(_editBuffer.Text.Substring(start, length));
296296
}
297297

298298
public bool PerformPrivateCommand(string? action, Bundle? data)

src/Android/Avalonia.Android/Platform/Input/TextEditBuffer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public string? ComposingText
9696
SelectionStart = Selection.Start,
9797
SelectionEnd = Selection.End,
9898
StartOffset = 0,
99-
Text = new SpannableString(Text)
99+
Text = new Java.Lang.String(Text)
100100
};
101101

102102
internal void Remove(int index, int length)

0 commit comments

Comments
 (0)