1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-12 06:13:21 +00:00

OnComplete return type, autocorrect, and autocapitalize implemented for android.

This commit is contained in:
Kyle Spearrin
2016-05-23 22:50:32 -04:00
parent 7ce1eec96d
commit dd9463fca2
4 changed files with 76 additions and 5 deletions

View File

@@ -3,8 +3,11 @@ using System.ComponentModel;
using Android.Graphics;
using Android.Text;
using Android.Text.Method;
using Android.Views.InputMethods;
using Android.Widget;
using Bit.Android.Controls;
using Bit.App.Controls;
using Bit.App.Enums;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
@@ -27,6 +30,29 @@ namespace Bit.Android.Controls
SetBorder(view);
SetMaxLength(view);
SetReturnType(view);
// Editor Action is called when the return button is pressed
Control.EditorAction += (object sender, TextView.EditorActionEventArgs args) =>
{
if(view.ReturnType != ReturnType.Next)
{
view.Unfocus();
}
// Call all the methods attached to base_entry event handler Completed
view.InvokeCompleted();
};
if(view.DisableAutocapitalize)
{
Control.SetRawInputType(Control.InputType |= InputTypes.TextVariationEmailAddress);
}
if(view.Autocorrect.HasValue)
{
Control.SetRawInputType(Control.InputType |= InputTypes.TextFlagNoSuggestions);
}
}
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
@@ -49,6 +75,35 @@ namespace Bit.Android.Controls
}
}
private void SetReturnType(ExtendedEntry view)
{
if(view.ReturnType.HasValue)
{
switch(view.ReturnType.Value)
{
case ReturnType.Go:
Control.ImeOptions = ImeAction.Go;
Control.SetImeActionLabel("Go", ImeAction.Go);
break;
case ReturnType.Next:
Control.ImeOptions = ImeAction.Next;
Control.SetImeActionLabel("Next", ImeAction.Next);
break;
case ReturnType.Search:
Control.ImeOptions = ImeAction.Search;
Control.SetImeActionLabel("Search", ImeAction.Search);
break;
case ReturnType.Send:
Control.ImeOptions = ImeAction.Send;
Control.SetImeActionLabel("Send", ImeAction.Send);
break;
default:
Control.SetImeActionLabel("Done", ImeAction.Done);
break;
}
}
}
private void SetBorder(ExtendedEntry view)
{
if(!view.HasBorder)