1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-25 20:53:25 +00:00

Extended controls

This commit is contained in:
Kyle Spearrin
2016-05-09 23:25:37 -04:00
parent b4144a393a
commit 3f251d0d12
14 changed files with 336 additions and 16 deletions

View File

@@ -196,6 +196,7 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Controls\ExtendedEntryRenderer.cs" />
<Compile Include="Resources\Resource.Designer.cs" />
<Compile Include="Services\ClipboardService.cs" />
<Compile Include="Services\KeyStoreStorageService.cs" />

View File

@@ -0,0 +1,75 @@
using System;
using System.ComponentModel;
using Android.Graphics;
using Android.Text;
using Android.Text.Method;
using Bit.Android.Controls;
using Bit.App.Controls;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
[assembly: ExportRenderer(typeof(ExtendedEntry), typeof(ExtendedEntryRenderer))]
namespace Bit.Android.Controls
{
public class ExtendedEntryRenderer : EntryRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
{
base.OnElementChanged(e);
var view = (ExtendedEntry)Element;
if(Control != null && e.NewElement != null && e.NewElement.IsPassword)
{
Control.SetTypeface(Typeface.Default, TypefaceStyle.Normal);
Control.TransformationMethod = new PasswordTransformationMethod();
}
SetBorder(view);
SetPlaceholderTextColor(view);
SetMaxLength(view);
}
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
{
var view = (ExtendedEntry)Element;
if(e.PropertyName == ExtendedEntry.HasBorderProperty.PropertyName
|| e.PropertyName == ExtendedEntry.HasOnlyBottomBorderProperty.PropertyName
|| e.PropertyName == ExtendedEntry.BorderColorProperty.PropertyName)
{
SetBorder(view);
}
if(e.PropertyName == ExtendedEntry.PlaceholderTextColorProperty.PropertyName)
{
SetPlaceholderTextColor(view);
}
else
{
base.OnElementPropertyChanged(sender, e);
if(e.PropertyName == VisualElement.BackgroundColorProperty.PropertyName)
{
Control.SetBackgroundColor(view.BackgroundColor.ToAndroid());
}
}
}
private void SetBorder(ExtendedEntry view)
{
//Not suported on Android
}
private void SetMaxLength(ExtendedEntry view)
{
Control.SetFilters(new IInputFilter[] { new InputFilterLengthFilter(view.MaxLength) });
}
private void SetPlaceholderTextColor(ExtendedEntry view)
{
if(view.PlaceholderTextColor != Xamarin.Forms.Color.Default)
{
Control.SetHintTextColor(view.PlaceholderTextColor.ToAndroid());
}
}
}
}

View File

@@ -2,5 +2,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="Bit.Android" android:versionCode="1" android:versionName="0.0.1" android:installLocation="auto">
<uses-sdk android:minSdkVersion="15" android:targetSdkVersion="23" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:label="bitwarden"></application>
<application android:label="bitwarden" android:theme="@android:style/Theme.Material.Light.DarkActionBar"></application>
</manifest>