mirror of
https://github.com/bitwarden/android.git
synced 2024-12-25 18:38:27 +03:00
Workaround for disabling predictive text in visible password fields (#983)
* Workaround for disabling predictive text in visible password fields * Fix for non-master branch iOS builds (#984) * Enable extra workflow steps to allow iOS builds to succeed from non-master branch * re-enable provisioning profile setup
This commit is contained in:
parent
2834e25151
commit
a458b9bc88
1 changed files with 42 additions and 1 deletions
|
@ -1,5 +1,9 @@
|
||||||
using Android.Content;
|
using System.ComponentModel;
|
||||||
|
using Android.Content;
|
||||||
|
using Android.Graphics;
|
||||||
|
using Android.Text;
|
||||||
using Android.Views.InputMethods;
|
using Android.Views.InputMethods;
|
||||||
|
using Android.Widget;
|
||||||
using Bit.Droid.Renderers;
|
using Bit.Droid.Renderers;
|
||||||
using Xamarin.Forms;
|
using Xamarin.Forms;
|
||||||
using Xamarin.Forms.Platform.Android;
|
using Xamarin.Forms.Platform.Android;
|
||||||
|
@ -24,5 +28,42 @@ namespace Bit.Droid.Renderers
|
||||||
(ImeAction)ImeFlags.NoExtractUi;
|
(ImeAction)ImeFlags.NoExtractUi;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Workaround for failure to disable text prediction on non-password fields
|
||||||
|
// see https://github.com/xamarin/Xamarin.Forms/issues/10857
|
||||||
|
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||||
|
{
|
||||||
|
base.OnElementPropertyChanged(sender, e);
|
||||||
|
|
||||||
|
// Check if changed property is "IsPassword", otherwise ignore
|
||||||
|
if (e.PropertyName == Entry.IsPasswordProperty.PropertyName)
|
||||||
|
{
|
||||||
|
// Check if field type is text, otherwise ignore (numeric passwords, etc.)
|
||||||
|
EditText.InputType = Element.Keyboard.ToInputType();
|
||||||
|
if ((EditText.InputType & InputTypes.ClassText) == InputTypes.ClassText)
|
||||||
|
{
|
||||||
|
if (Element.IsPassword)
|
||||||
|
{
|
||||||
|
// Element is a password field, set inputType to TextVariationPassword which disables
|
||||||
|
// predictive text by default
|
||||||
|
EditText.InputType = EditText.InputType | InputTypes.TextVariationPassword;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Element is not a password field, set inputType to TextVariationVisiblePassword to
|
||||||
|
// disable predictive text while still displaying the content.
|
||||||
|
EditText.InputType = EditText.InputType | InputTypes.TextVariationVisiblePassword;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The workaround above forces a reset of the style properties, so we need to re-apply the font.
|
||||||
|
// see https://xamarin.github.io/bugzilla-archives/33/33666/bug.html
|
||||||
|
var typeface = Typeface.CreateFromAsset(Context.Assets, "RobotoMono_Regular.ttf");
|
||||||
|
if (Control is TextView label)
|
||||||
|
{
|
||||||
|
label.Typeface = typeface;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue