mirror of
https://github.com/bitwarden/mobile.git
synced 2025-02-22 02:11:25 +01:00
Android styles and theme, updated to extended controls
This commit is contained in:
parent
3f251d0d12
commit
15be1cbf43
@ -224,6 +224,15 @@
|
|||||||
<Name>App</Name>
|
<Name>App</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<AndroidResource Include="Resources\values-v21\styles.xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<AndroidResource Include="Resources\values\styles.xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<AndroidResource Include="Resources\values\colors.xml" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
|
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
|
||||||
<Import Project="..\..\packages\Xamarin.Android.Support.Vector.Drawable.23.3.0\build\Xamarin.Android.Support.Vector.Drawable.targets" Condition="Exists('..\..\packages\Xamarin.Android.Support.Vector.Drawable.23.3.0\build\Xamarin.Android.Support.Vector.Drawable.targets')" />
|
<Import Project="..\..\packages\Xamarin.Android.Support.Vector.Drawable.23.3.0\build\Xamarin.Android.Support.Vector.Drawable.targets" Condition="Exists('..\..\packages\Xamarin.Android.Support.Vector.Drawable.23.3.0\build\Xamarin.Android.Support.Vector.Drawable.targets')" />
|
||||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||||
|
@ -26,7 +26,6 @@ namespace Bit.Android.Controls
|
|||||||
}
|
}
|
||||||
|
|
||||||
SetBorder(view);
|
SetBorder(view);
|
||||||
SetPlaceholderTextColor(view);
|
|
||||||
SetMaxLength(view);
|
SetMaxLength(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,14 +35,10 @@ namespace Bit.Android.Controls
|
|||||||
|
|
||||||
if(e.PropertyName == ExtendedEntry.HasBorderProperty.PropertyName
|
if(e.PropertyName == ExtendedEntry.HasBorderProperty.PropertyName
|
||||||
|| e.PropertyName == ExtendedEntry.HasOnlyBottomBorderProperty.PropertyName
|
|| e.PropertyName == ExtendedEntry.HasOnlyBottomBorderProperty.PropertyName
|
||||||
|| e.PropertyName == ExtendedEntry.BorderColorProperty.PropertyName)
|
|| e.PropertyName == ExtendedEntry.BottomBorderColorProperty.PropertyName)
|
||||||
{
|
{
|
||||||
SetBorder(view);
|
SetBorder(view);
|
||||||
}
|
}
|
||||||
if(e.PropertyName == ExtendedEntry.PlaceholderTextColorProperty.PropertyName)
|
|
||||||
{
|
|
||||||
SetPlaceholderTextColor(view);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
base.OnElementPropertyChanged(sender, e);
|
base.OnElementPropertyChanged(sender, e);
|
||||||
@ -63,13 +58,5 @@ namespace Bit.Android.Controls
|
|||||||
{
|
{
|
||||||
Control.SetFilters(new IInputFilter[] { new InputFilterLengthFilter(view.MaxLength) });
|
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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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">
|
<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-sdk android:minSdkVersion="15" android:targetSdkVersion="23" />
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<application android:label="bitwarden" android:theme="@android:style/Theme.Material.Light.DarkActionBar"></application>
|
<application android:label="bitwarden" android:theme="@style/BitwardenTheme"></application>
|
||||||
</manifest>
|
</manifest>
|
66
src/Android/Resources/Resource.Designer.cs
generated
66
src/Android/Resources/Resource.Designer.cs
generated
@ -1166,32 +1166,32 @@ namespace Bit.Android
|
|||||||
public partial class Color
|
public partial class Color
|
||||||
{
|
{
|
||||||
|
|
||||||
// aapt resource value: 0x7f0b0048
|
// aapt resource value: 0x7f0b004d
|
||||||
public const int abc_background_cache_hint_selector_material_dark = 2131427400;
|
public const int abc_background_cache_hint_selector_material_dark = 2131427405;
|
||||||
|
|
||||||
// aapt resource value: 0x7f0b0049
|
// aapt resource value: 0x7f0b004e
|
||||||
public const int abc_background_cache_hint_selector_material_light = 2131427401;
|
public const int abc_background_cache_hint_selector_material_light = 2131427406;
|
||||||
|
|
||||||
// aapt resource value: 0x7f0b004a
|
// aapt resource value: 0x7f0b004f
|
||||||
public const int abc_color_highlight_material = 2131427402;
|
public const int abc_color_highlight_material = 2131427407;
|
||||||
|
|
||||||
// aapt resource value: 0x7f0b0004
|
// aapt resource value: 0x7f0b0004
|
||||||
public const int abc_input_method_navigation_guard = 2131427332;
|
public const int abc_input_method_navigation_guard = 2131427332;
|
||||||
|
|
||||||
// aapt resource value: 0x7f0b004b
|
// aapt resource value: 0x7f0b0050
|
||||||
public const int abc_primary_text_disable_only_material_dark = 2131427403;
|
public const int abc_primary_text_disable_only_material_dark = 2131427408;
|
||||||
|
|
||||||
// aapt resource value: 0x7f0b004c
|
// aapt resource value: 0x7f0b0051
|
||||||
public const int abc_primary_text_disable_only_material_light = 2131427404;
|
public const int abc_primary_text_disable_only_material_light = 2131427409;
|
||||||
|
|
||||||
// aapt resource value: 0x7f0b004d
|
// aapt resource value: 0x7f0b0052
|
||||||
public const int abc_primary_text_material_dark = 2131427405;
|
public const int abc_primary_text_material_dark = 2131427410;
|
||||||
|
|
||||||
// aapt resource value: 0x7f0b004e
|
// aapt resource value: 0x7f0b0053
|
||||||
public const int abc_primary_text_material_light = 2131427406;
|
public const int abc_primary_text_material_light = 2131427411;
|
||||||
|
|
||||||
// aapt resource value: 0x7f0b004f
|
// aapt resource value: 0x7f0b0054
|
||||||
public const int abc_search_url_text = 2131427407;
|
public const int abc_search_url_text = 2131427412;
|
||||||
|
|
||||||
// aapt resource value: 0x7f0b0005
|
// aapt resource value: 0x7f0b0005
|
||||||
public const int abc_search_url_text_normal = 2131427333;
|
public const int abc_search_url_text_normal = 2131427333;
|
||||||
@ -1202,11 +1202,14 @@ namespace Bit.Android
|
|||||||
// aapt resource value: 0x7f0b0007
|
// aapt resource value: 0x7f0b0007
|
||||||
public const int abc_search_url_text_selected = 2131427335;
|
public const int abc_search_url_text_selected = 2131427335;
|
||||||
|
|
||||||
// aapt resource value: 0x7f0b0050
|
// aapt resource value: 0x7f0b0055
|
||||||
public const int abc_secondary_text_material_dark = 2131427408;
|
public const int abc_secondary_text_material_dark = 2131427413;
|
||||||
|
|
||||||
// aapt resource value: 0x7f0b0051
|
// aapt resource value: 0x7f0b0056
|
||||||
public const int abc_secondary_text_material_light = 2131427409;
|
public const int abc_secondary_text_material_light = 2131427414;
|
||||||
|
|
||||||
|
// aapt resource value: 0x7f0b004c
|
||||||
|
public const int accent = 2131427404;
|
||||||
|
|
||||||
// aapt resource value: 0x7f0b0008
|
// aapt resource value: 0x7f0b0008
|
||||||
public const int accent_material_dark = 2131427336;
|
public const int accent_material_dark = 2131427336;
|
||||||
@ -1262,6 +1265,9 @@ namespace Bit.Android
|
|||||||
// aapt resource value: 0x7f0b0003
|
// aapt resource value: 0x7f0b0003
|
||||||
public const int cardview_shadow_start_color = 2131427331;
|
public const int cardview_shadow_start_color = 2131427331;
|
||||||
|
|
||||||
|
// aapt resource value: 0x7f0b0049
|
||||||
|
public const int darkgray = 2131427401;
|
||||||
|
|
||||||
// aapt resource value: 0x7f0b003e
|
// aapt resource value: 0x7f0b003e
|
||||||
public const int design_fab_shadow_end_color = 2131427390;
|
public const int design_fab_shadow_end_color = 2131427390;
|
||||||
|
|
||||||
@ -1310,6 +1316,9 @@ namespace Bit.Android
|
|||||||
// aapt resource value: 0x7f0b001b
|
// aapt resource value: 0x7f0b001b
|
||||||
public const int foreground_material_light = 2131427355;
|
public const int foreground_material_light = 2131427355;
|
||||||
|
|
||||||
|
// aapt resource value: 0x7f0b004a
|
||||||
|
public const int gray = 2131427402;
|
||||||
|
|
||||||
// aapt resource value: 0x7f0b001c
|
// aapt resource value: 0x7f0b001c
|
||||||
public const int highlighted_text_material_dark = 2131427356;
|
public const int highlighted_text_material_dark = 2131427356;
|
||||||
|
|
||||||
@ -1358,6 +1367,9 @@ namespace Bit.Android
|
|||||||
// aapt resource value: 0x7f0b002b
|
// aapt resource value: 0x7f0b002b
|
||||||
public const int material_grey_900 = 2131427371;
|
public const int material_grey_900 = 2131427371;
|
||||||
|
|
||||||
|
// aapt resource value: 0x7f0b004b
|
||||||
|
public const int primary = 2131427403;
|
||||||
|
|
||||||
// aapt resource value: 0x7f0b002c
|
// aapt resource value: 0x7f0b002c
|
||||||
public const int primary_dark_material_dark = 2131427372;
|
public const int primary_dark_material_dark = 2131427372;
|
||||||
|
|
||||||
@ -1406,11 +1418,11 @@ namespace Bit.Android
|
|||||||
// aapt resource value: 0x7f0b003b
|
// aapt resource value: 0x7f0b003b
|
||||||
public const int switch_thumb_disabled_material_light = 2131427387;
|
public const int switch_thumb_disabled_material_light = 2131427387;
|
||||||
|
|
||||||
// aapt resource value: 0x7f0b0052
|
// aapt resource value: 0x7f0b0057
|
||||||
public const int switch_thumb_material_dark = 2131427410;
|
public const int switch_thumb_material_dark = 2131427415;
|
||||||
|
|
||||||
// aapt resource value: 0x7f0b0053
|
// aapt resource value: 0x7f0b0058
|
||||||
public const int switch_thumb_material_light = 2131427411;
|
public const int switch_thumb_material_light = 2131427416;
|
||||||
|
|
||||||
// aapt resource value: 0x7f0b003c
|
// aapt resource value: 0x7f0b003c
|
||||||
public const int switch_thumb_normal_material_dark = 2131427388;
|
public const int switch_thumb_normal_material_dark = 2131427388;
|
||||||
@ -1418,6 +1430,9 @@ namespace Bit.Android
|
|||||||
// aapt resource value: 0x7f0b003d
|
// aapt resource value: 0x7f0b003d
|
||||||
public const int switch_thumb_normal_material_light = 2131427389;
|
public const int switch_thumb_normal_material_light = 2131427389;
|
||||||
|
|
||||||
|
// aapt resource value: 0x7f0b0048
|
||||||
|
public const int white = 2131427400;
|
||||||
|
|
||||||
static Color()
|
static Color()
|
||||||
{
|
{
|
||||||
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
|
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
|
||||||
@ -3610,6 +3625,9 @@ namespace Bit.Android
|
|||||||
// aapt resource value: 0x7f0a015b
|
// aapt resource value: 0x7f0a015b
|
||||||
public const int Base_Widget_Design_TabLayout = 2131362139;
|
public const int Base_Widget_Design_TabLayout = 2131362139;
|
||||||
|
|
||||||
|
// aapt resource value: 0x7f0a0172
|
||||||
|
public const int BitwardenTheme = 2131362162;
|
||||||
|
|
||||||
// aapt resource value: 0x7f0a0017
|
// aapt resource value: 0x7f0a0017
|
||||||
public const int CardView = 2131361815;
|
public const int CardView = 2131361815;
|
||||||
|
|
||||||
|
9
src/Android/Resources/values-v21/styles.xml
Normal file
9
src/Android/Resources/values-v21/styles.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<resources>
|
||||||
|
<style name="BitwardenTheme" parent="android:Theme.Material.Light.DarkActionBar">
|
||||||
|
<item name="android:colorPrimary">@color/primary</item>
|
||||||
|
<item name="android:textColorPrimary">@color/darkgray</item>
|
||||||
|
<item name="android:colorAccent">@color/accent</item>
|
||||||
|
<item name="android:windowBackground">@color/white</item>
|
||||||
|
</style>
|
||||||
|
</resources>
|
8
src/Android/Resources/values/colors.xml
Normal file
8
src/Android/Resources/values/colors.xml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<resources>
|
||||||
|
<color name="white">#FFFFFF</color>
|
||||||
|
<color name="darkgray">#333333</color>
|
||||||
|
<color name="gray">#738182</color>
|
||||||
|
<color name="primary">#222d32</color>
|
||||||
|
<color name="accent">#3c8dbc</color>
|
||||||
|
</resources>
|
9
src/Android/Resources/values/styles.xml
Normal file
9
src/Android/Resources/values/styles.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<resources>
|
||||||
|
<style name="BitwardenTheme" parent="android:Theme.Holo.Light.DarkActionBar">
|
||||||
|
<item name="android:colorPrimary">@color/primary</item>
|
||||||
|
<item name="android:textColorPrimary">@color/darkgray</item>
|
||||||
|
<item name="android:colorAccent">@color/accent</item>
|
||||||
|
<item name="android:windowBackground">@color/white</item>
|
||||||
|
</style>
|
||||||
|
</resources>
|
@ -46,6 +46,7 @@
|
|||||||
<Compile Include="Behaviors\RequiredValidationBehavior.cs" />
|
<Compile Include="Behaviors\RequiredValidationBehavior.cs" />
|
||||||
<Compile Include="Controls\EntryLabel.cs" />
|
<Compile Include="Controls\EntryLabel.cs" />
|
||||||
<Compile Include="Controls\BottomBorderEntry.cs" />
|
<Compile Include="Controls\BottomBorderEntry.cs" />
|
||||||
|
<Compile Include="Controls\ExtendedPicker.cs" />
|
||||||
<Compile Include="Controls\ExtendedEntry.cs" />
|
<Compile Include="Controls\ExtendedEntry.cs" />
|
||||||
<Compile Include="Controls\ExtendedTabbedPage.cs" />
|
<Compile Include="Controls\ExtendedTabbedPage.cs" />
|
||||||
<Compile Include="Models\Api\ApiError.cs" />
|
<Compile Include="Models\Api\ApiError.cs" />
|
||||||
|
@ -7,7 +7,7 @@ namespace Bit.App.Controls
|
|||||||
public BottomBorderEntry()
|
public BottomBorderEntry()
|
||||||
{
|
{
|
||||||
HasBorder = HasOnlyBottomBorder = true;
|
HasBorder = HasOnlyBottomBorder = true;
|
||||||
BorderColor = Color.FromHex("d2d6de");
|
BottomBorderColor = Color.FromHex("d2d6de");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,11 +11,8 @@ namespace Bit.App.Controls
|
|||||||
public static readonly BindableProperty HasOnlyBottomBorderProperty =
|
public static readonly BindableProperty HasOnlyBottomBorderProperty =
|
||||||
BindableProperty.Create(nameof(HasOnlyBottomBorder), typeof(bool), typeof(ExtendedEntry), false);
|
BindableProperty.Create(nameof(HasOnlyBottomBorder), typeof(bool), typeof(ExtendedEntry), false);
|
||||||
|
|
||||||
public static readonly BindableProperty BorderColorProperty =
|
public static readonly BindableProperty BottomBorderColorProperty =
|
||||||
BindableProperty.Create(nameof(BorderColor), typeof(Color), typeof(ExtendedEntry), Color.Default);
|
BindableProperty.Create(nameof(BottomBorderColor), typeof(Color), typeof(ExtendedEntry), Color.Default);
|
||||||
|
|
||||||
public static readonly BindableProperty PlaceholderTextColorProperty =
|
|
||||||
BindableProperty.Create(nameof(PlaceholderTextColor), typeof(Color), typeof(ExtendedEntry), Color.Default);
|
|
||||||
|
|
||||||
public static readonly BindableProperty MaxLengthProperty =
|
public static readonly BindableProperty MaxLengthProperty =
|
||||||
BindableProperty.Create(nameof(MaxLength), typeof(int), typeof(ExtendedEntry), int.MaxValue);
|
BindableProperty.Create(nameof(MaxLength), typeof(int), typeof(ExtendedEntry), int.MaxValue);
|
||||||
@ -32,16 +29,10 @@ namespace Bit.App.Controls
|
|||||||
set { SetValue(HasOnlyBottomBorderProperty, value); }
|
set { SetValue(HasOnlyBottomBorderProperty, value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color BorderColor
|
public Color BottomBorderColor
|
||||||
{
|
{
|
||||||
get { return (Color)GetValue(BorderColorProperty); }
|
get { return (Color)GetValue(BottomBorderColorProperty); }
|
||||||
set { SetValue(BorderColorProperty, value); }
|
set { SetValue(BottomBorderColorProperty, value); }
|
||||||
}
|
|
||||||
|
|
||||||
public Color PlaceholderTextColor
|
|
||||||
{
|
|
||||||
get { return (Color)GetValue(PlaceholderTextColorProperty); }
|
|
||||||
set { SetValue(PlaceholderTextColorProperty, value); }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int MaxLength
|
public int MaxLength
|
||||||
|
35
src/App/Controls/ExtendedPicker.cs
Normal file
35
src/App/Controls/ExtendedPicker.cs
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
using System;
|
||||||
|
using Xamarin.Forms;
|
||||||
|
|
||||||
|
namespace Bit.App.Controls
|
||||||
|
{
|
||||||
|
public class ExtendedPicker : Picker
|
||||||
|
{
|
||||||
|
public static readonly BindableProperty HasBorderProperty =
|
||||||
|
BindableProperty.Create(nameof(HasBorder), typeof(bool), typeof(ExtendedEntry), true);
|
||||||
|
|
||||||
|
public static readonly BindableProperty HasOnlyBottomBorderProperty =
|
||||||
|
BindableProperty.Create(nameof(HasOnlyBottomBorder), typeof(bool), typeof(ExtendedEntry), false);
|
||||||
|
|
||||||
|
public static readonly BindableProperty BottomBorderColorProperty =
|
||||||
|
BindableProperty.Create(nameof(BottomBorderColor), typeof(Color), typeof(ExtendedEntry), Color.Default);
|
||||||
|
|
||||||
|
public bool HasBorder
|
||||||
|
{
|
||||||
|
get { return (bool)GetValue(HasBorderProperty); }
|
||||||
|
set { SetValue(HasBorderProperty, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool HasOnlyBottomBorder
|
||||||
|
{
|
||||||
|
get { return (bool)GetValue(HasOnlyBottomBorderProperty); }
|
||||||
|
set { SetValue(HasOnlyBottomBorderProperty, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public Color BottomBorderColor
|
||||||
|
{
|
||||||
|
get { return (Color)GetValue(BottomBorderColorProperty); }
|
||||||
|
set { SetValue(BottomBorderColorProperty, value); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -2,6 +2,7 @@
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Acr.UserDialogs;
|
using Acr.UserDialogs;
|
||||||
using Bit.App.Abstractions;
|
using Bit.App.Abstractions;
|
||||||
|
using Bit.App.Controls;
|
||||||
using Bit.App.Resources;
|
using Bit.App.Resources;
|
||||||
using Plugin.Connectivity.Abstractions;
|
using Plugin.Connectivity.Abstractions;
|
||||||
using Xamarin.Forms;
|
using Xamarin.Forms;
|
||||||
@ -29,17 +30,25 @@ namespace Bit.App.Pages
|
|||||||
var syncButton = new Button
|
var syncButton = new Button
|
||||||
{
|
{
|
||||||
Text = "Sync Vault",
|
Text = "Sync Vault",
|
||||||
Command = new Command(async () => await SyncAsync())
|
Command = new Command( async () => await SyncAsync() )
|
||||||
};
|
};
|
||||||
|
|
||||||
var stackLayout = new StackLayout { };
|
var stackLayout = new StackLayout { };
|
||||||
stackLayout.Children.Add(syncButton);
|
stackLayout.Children.Add( syncButton );
|
||||||
|
stackLayout.Children.Add( new ExtendedEntry
|
||||||
|
{
|
||||||
|
BottomBorderColor = Color.Black,
|
||||||
|
HasBorder = true,
|
||||||
|
HasOnlyBottomBorder = true,
|
||||||
|
Placeholder = "Some placeholder",
|
||||||
|
PlaceholderColor = Color.Red
|
||||||
|
} );
|
||||||
|
|
||||||
Title = "Sync";
|
Title = "Sync";
|
||||||
Content = stackLayout;
|
Content = stackLayout;
|
||||||
Icon = "fa-refresh";
|
Icon = "fa-refresh";
|
||||||
|
|
||||||
if(!_connectivity.IsConnected)
|
if( !_connectivity.IsConnected )
|
||||||
{
|
{
|
||||||
AlertNoConnection();
|
AlertNoConnection();
|
||||||
}
|
}
|
||||||
@ -47,28 +56,28 @@ namespace Bit.App.Pages
|
|||||||
|
|
||||||
public async Task SyncAsync()
|
public async Task SyncAsync()
|
||||||
{
|
{
|
||||||
if(!_connectivity.IsConnected)
|
if( !_connectivity.IsConnected )
|
||||||
{
|
{
|
||||||
AlertNoConnection();
|
AlertNoConnection();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_userDialogs.ShowLoading("Syncing...", MaskType.Black);
|
_userDialogs.ShowLoading( "Syncing...", MaskType.Black );
|
||||||
var succeeded = await _syncService.SyncAsync();
|
var succeeded = await _syncService.SyncAsync();
|
||||||
_userDialogs.HideLoading();
|
_userDialogs.HideLoading();
|
||||||
if(succeeded)
|
if( succeeded )
|
||||||
{
|
{
|
||||||
_userDialogs.SuccessToast("Syncing complete.");
|
_userDialogs.SuccessToast( "Syncing complete." );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_userDialogs.ErrorToast("Syncing failed.");
|
_userDialogs.ErrorToast( "Syncing failed." );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AlertNoConnection()
|
public void AlertNoConnection()
|
||||||
{
|
{
|
||||||
DisplayAlert(AppResources.InternetConnectionRequiredTitle, AppResources.InternetConnectionRequiredMessage, AppResources.Ok);
|
DisplayAlert( AppResources.InternetConnectionRequiredTitle, AppResources.InternetConnectionRequiredMessage, AppResources.Ok );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,34 +30,39 @@ namespace Bit.App.Pages
|
|||||||
|
|
||||||
private void Init()
|
private void Init()
|
||||||
{
|
{
|
||||||
var folders = _folderService.GetAllAsync().GetAwaiter().GetResult().OrderBy(f => f.Name?.Decrypt());
|
var folders = _folderService.GetAllAsync().GetAwaiter().GetResult().OrderBy( f => f.Name?.Decrypt() );
|
||||||
|
|
||||||
var uriEntry = new BottomBorderEntry { Keyboard = Keyboard.Url };
|
var uriEntry = new BottomBorderEntry { Keyboard = Keyboard.Url };
|
||||||
var nameEntry = new BottomBorderEntry();
|
var nameEntry = new BottomBorderEntry();
|
||||||
var folderPicker = new Picker { Title = AppResources.Folder };
|
var folderPicker = new ExtendedPicker
|
||||||
folderPicker.Items.Add(AppResources.FolderNone);
|
|
||||||
folderPicker.SelectedIndex = 0;
|
|
||||||
foreach(var folder in folders)
|
|
||||||
{
|
{
|
||||||
folderPicker.Items.Add(folder.Name.Decrypt());
|
Title = AppResources.Folder,
|
||||||
|
BottomBorderColor = Color.FromHex( "d2d6de" ),
|
||||||
|
HasOnlyBottomBorder = true
|
||||||
|
};
|
||||||
|
folderPicker.Items.Add( AppResources.FolderNone );
|
||||||
|
folderPicker.SelectedIndex = 0;
|
||||||
|
foreach( var folder in folders )
|
||||||
|
{
|
||||||
|
folderPicker.Items.Add( folder.Name.Decrypt() );
|
||||||
}
|
}
|
||||||
var usernameEntry = new BottomBorderEntry();
|
var usernameEntry = new BottomBorderEntry();
|
||||||
var passwordEntry = new BottomBorderEntry { IsPassword = true };
|
var passwordEntry = new BottomBorderEntry { IsPassword = true };
|
||||||
var notesEditor = new Editor();
|
var notesEditor = new Editor { HeightRequest = 75 };
|
||||||
|
|
||||||
var stackLayout = new StackLayout { Padding = new Thickness(15) };
|
var stackLayout = new StackLayout { Padding = new Thickness( 15 ) };
|
||||||
stackLayout.Children.Add(new EntryLabel { Text = AppResources.URI });
|
stackLayout.Children.Add( new EntryLabel { Text = AppResources.URI } );
|
||||||
stackLayout.Children.Add(uriEntry);
|
stackLayout.Children.Add( uriEntry );
|
||||||
stackLayout.Children.Add(new EntryLabel { Text = AppResources.Name });
|
stackLayout.Children.Add( new EntryLabel { Text = AppResources.Name, Margin = new Thickness( 0, 15, 0, 0 ) } );
|
||||||
stackLayout.Children.Add(nameEntry);
|
stackLayout.Children.Add( nameEntry );
|
||||||
stackLayout.Children.Add(new EntryLabel { Text = AppResources.Folder });
|
stackLayout.Children.Add( new EntryLabel { Text = AppResources.Folder, Margin = new Thickness( 0, 15, 0, 0 ) } );
|
||||||
stackLayout.Children.Add(folderPicker);
|
stackLayout.Children.Add( folderPicker );
|
||||||
stackLayout.Children.Add(new EntryLabel { Text = AppResources.Username });
|
stackLayout.Children.Add( new EntryLabel { Text = AppResources.Username, Margin = new Thickness( 0, 15, 0, 0 ) } );
|
||||||
stackLayout.Children.Add(usernameEntry);
|
stackLayout.Children.Add( usernameEntry );
|
||||||
stackLayout.Children.Add(new EntryLabel { Text = AppResources.Password });
|
stackLayout.Children.Add( new EntryLabel { Text = AppResources.Password, Margin = new Thickness( 0, 15, 0, 0 ) } );
|
||||||
stackLayout.Children.Add(passwordEntry);
|
stackLayout.Children.Add( passwordEntry );
|
||||||
stackLayout.Children.Add(new EntryLabel { Text = AppResources.Notes });
|
stackLayout.Children.Add( new EntryLabel { Text = AppResources.Notes, Margin = new Thickness( 0, 15, 0, 0 ) } );
|
||||||
stackLayout.Children.Add(notesEditor);
|
stackLayout.Children.Add( notesEditor );
|
||||||
|
|
||||||
var scrollView = new ScrollView
|
var scrollView = new ScrollView
|
||||||
{
|
{
|
||||||
@ -65,54 +70,54 @@ namespace Bit.App.Pages
|
|||||||
Orientation = ScrollOrientation.Vertical
|
Orientation = ScrollOrientation.Vertical
|
||||||
};
|
};
|
||||||
|
|
||||||
var saveToolBarItem = new ToolbarItem(AppResources.Save, null, async () =>
|
var saveToolBarItem = new ToolbarItem( AppResources.Save, null, async () =>
|
||||||
{
|
{
|
||||||
if(!_connectivity.IsConnected)
|
if( !_connectivity.IsConnected )
|
||||||
{
|
{
|
||||||
AlertNoConnection();
|
AlertNoConnection();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(string.IsNullOrWhiteSpace(uriEntry.Text))
|
if( string.IsNullOrWhiteSpace( uriEntry.Text ) )
|
||||||
{
|
{
|
||||||
await DisplayAlert(AppResources.AnErrorHasOccurred, string.Format(AppResources.ValidationFieldRequired, AppResources.URI), AppResources.Ok);
|
await DisplayAlert( AppResources.AnErrorHasOccurred, string.Format( AppResources.ValidationFieldRequired, AppResources.URI ), AppResources.Ok );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(string.IsNullOrWhiteSpace(nameEntry.Text))
|
if( string.IsNullOrWhiteSpace( nameEntry.Text ) )
|
||||||
{
|
{
|
||||||
await DisplayAlert(AppResources.AnErrorHasOccurred, string.Format(AppResources.ValidationFieldRequired, AppResources.Name), AppResources.Ok);
|
await DisplayAlert( AppResources.AnErrorHasOccurred, string.Format( AppResources.ValidationFieldRequired, AppResources.Name ), AppResources.Ok );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var site = new Site
|
var site = new Site
|
||||||
{
|
{
|
||||||
Uri = uriEntry.Text.Encrypt(),
|
Uri = uriEntry.Text.Encrypt(),
|
||||||
Name = nameEntry.Text.Encrypt(),
|
Name = nameEntry.Text.Encrypt(),
|
||||||
Username = usernameEntry.Text?.Encrypt(),
|
Username = usernameEntry.Text?.Encrypt(),
|
||||||
Password = passwordEntry.Text?.Encrypt(),
|
Password = passwordEntry.Text?.Encrypt(),
|
||||||
Notes = notesEditor.Text?.Encrypt(),
|
Notes = notesEditor.Text?.Encrypt(),
|
||||||
};
|
};
|
||||||
|
|
||||||
if(folderPicker.SelectedIndex > 0)
|
if( folderPicker.SelectedIndex > 0 )
|
||||||
{
|
{
|
||||||
site.FolderId = folders.ElementAt(folderPicker.SelectedIndex - 1).Id;
|
site.FolderId = folders.ElementAt( folderPicker.SelectedIndex - 1 ).Id;
|
||||||
}
|
}
|
||||||
|
|
||||||
var saveTask = _siteService.SaveAsync(site);
|
var saveTask = _siteService.SaveAsync( site );
|
||||||
_userDialogs.ShowLoading("Saving...", MaskType.Black);
|
_userDialogs.ShowLoading( "Saving...", MaskType.Black );
|
||||||
await saveTask;
|
await saveTask;
|
||||||
|
|
||||||
_userDialogs.HideLoading();
|
_userDialogs.HideLoading();
|
||||||
await Navigation.PopAsync();
|
await Navigation.PopAsync();
|
||||||
_userDialogs.SuccessToast(nameEntry.Text, "New site created.");
|
_userDialogs.SuccessToast( nameEntry.Text, "New site created." );
|
||||||
}, ToolbarItemOrder.Default, 0);
|
}, ToolbarItemOrder.Default, 0 );
|
||||||
|
|
||||||
Title = AppResources.AddSite;
|
Title = AppResources.AddSite;
|
||||||
Content = scrollView;
|
Content = scrollView;
|
||||||
ToolbarItems.Add(saveToolBarItem);
|
ToolbarItems.Add( saveToolBarItem );
|
||||||
|
|
||||||
if(!_connectivity.IsConnected)
|
if( !_connectivity.IsConnected )
|
||||||
{
|
{
|
||||||
AlertNoConnection();
|
AlertNoConnection();
|
||||||
}
|
}
|
||||||
@ -120,7 +125,7 @@ namespace Bit.App.Pages
|
|||||||
|
|
||||||
private void AlertNoConnection()
|
private void AlertNoConnection()
|
||||||
{
|
{
|
||||||
DisplayAlert(AppResources.InternetConnectionRequiredTitle, AppResources.InternetConnectionRequiredMessage, AppResources.Ok);
|
DisplayAlert( AppResources.InternetConnectionRequiredTitle, AppResources.InternetConnectionRequiredMessage, AppResources.Ok );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@ namespace Bit.iOS.Controls
|
|||||||
if(view != null)
|
if(view != null)
|
||||||
{
|
{
|
||||||
SetBorder(view);
|
SetBorder(view);
|
||||||
SetPlaceholderTextColor(view);
|
|
||||||
SetMaxLength(view);
|
SetMaxLength(view);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -35,32 +34,28 @@ namespace Bit.iOS.Controls
|
|||||||
|
|
||||||
if(e.PropertyName == ExtendedEntry.HasBorderProperty.PropertyName
|
if(e.PropertyName == ExtendedEntry.HasBorderProperty.PropertyName
|
||||||
|| e.PropertyName == ExtendedEntry.HasOnlyBottomBorderProperty.PropertyName
|
|| e.PropertyName == ExtendedEntry.HasOnlyBottomBorderProperty.PropertyName
|
||||||
|| e.PropertyName == ExtendedEntry.BorderColorProperty.PropertyName)
|
|| e.PropertyName == ExtendedEntry.BottomBorderColorProperty.PropertyName)
|
||||||
{
|
{
|
||||||
SetBorder(view);
|
SetBorder(view);
|
||||||
}
|
}
|
||||||
if(e.PropertyName == ExtendedEntry.PlaceholderTextColorProperty.PropertyName)
|
|
||||||
{
|
|
||||||
SetPlaceholderTextColor(view);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetBorder(ExtendedEntry view)
|
private void SetBorder(ExtendedEntry view)
|
||||||
{
|
{
|
||||||
if(view.HasBorder && view.HasOnlyBottomBorder)
|
if(view.HasOnlyBottomBorder)
|
||||||
{
|
{
|
||||||
var borderLayer = new CALayer();
|
var borderLayer = new CALayer();
|
||||||
borderLayer.MasksToBounds = true;
|
borderLayer.MasksToBounds = true;
|
||||||
borderLayer.Frame = new CGRect(0f, Frame.Height / 2, Frame.Width, 1f);
|
borderLayer.Frame = new CGRect(0f, Frame.Height / 2, Frame.Width * 2, 1f);
|
||||||
borderLayer.BorderColor = view.BorderColor.ToCGColor();
|
borderLayer.BorderColor = view.BottomBorderColor.ToCGColor();
|
||||||
borderLayer.BorderWidth = 1.0f;
|
borderLayer.BorderWidth = 1f;
|
||||||
|
|
||||||
Control.Layer.AddSublayer(borderLayer);
|
Control.Layer.AddSublayer(borderLayer);
|
||||||
Control.BorderStyle = UITextBorderStyle.None;
|
Control.BorderStyle = UITextBorderStyle.None;
|
||||||
}
|
}
|
||||||
else if(view.HasBorder)
|
else if(view.HasBorder)
|
||||||
{
|
{
|
||||||
Control.BorderStyle = UITextBorderStyle.Line;
|
Control.BorderStyle = UITextBorderStyle.RoundedRect;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -76,20 +71,5 @@ namespace Bit.iOS.Controls
|
|||||||
return newLength <= view.MaxLength;
|
return newLength <= view.MaxLength;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetPlaceholderTextColor(ExtendedEntry view)
|
|
||||||
{
|
|
||||||
if(string.IsNullOrEmpty(view.Placeholder) == false && view.PlaceholderTextColor != Color.Default)
|
|
||||||
{
|
|
||||||
var placeholderString = new NSAttributedString(
|
|
||||||
view.Placeholder,
|
|
||||||
new UIStringAttributes()
|
|
||||||
{
|
|
||||||
ForegroundColor = view.PlaceholderTextColor.ToUIColor()
|
|
||||||
});
|
|
||||||
|
|
||||||
Control.AttributedPlaceholder = placeholderString;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
64
src/iOS/Controls/ExtendedPickerRenderer.cs
Normal file
64
src/iOS/Controls/ExtendedPickerRenderer.cs
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
using System;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using Bit.App.Controls;
|
||||||
|
using Bit.iOS.Controls;
|
||||||
|
using CoreAnimation;
|
||||||
|
using CoreGraphics;
|
||||||
|
using UIKit;
|
||||||
|
using Xamarin.Forms;
|
||||||
|
using Xamarin.Forms.Platform.iOS;
|
||||||
|
|
||||||
|
[assembly: ExportRenderer(typeof(ExtendedPicker), typeof( ExtendedPickerRenderer ) )]
|
||||||
|
namespace Bit.iOS.Controls
|
||||||
|
{
|
||||||
|
public class ExtendedPickerRenderer : PickerRenderer
|
||||||
|
{
|
||||||
|
protected override void OnElementChanged(ElementChangedEventArgs<Picker> e)
|
||||||
|
{
|
||||||
|
base.OnElementChanged(e);
|
||||||
|
|
||||||
|
var view = e.NewElement as ExtendedPicker;
|
||||||
|
if(view != null)
|
||||||
|
{
|
||||||
|
SetBorder(view);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||||
|
{
|
||||||
|
base.OnElementPropertyChanged(sender, e);
|
||||||
|
|
||||||
|
var view = (ExtendedPicker)Element;
|
||||||
|
|
||||||
|
if(e.PropertyName == ExtendedPicker.HasBorderProperty.PropertyName
|
||||||
|
|| e.PropertyName == ExtendedPicker.HasOnlyBottomBorderProperty.PropertyName
|
||||||
|
|| e.PropertyName == ExtendedPicker.BottomBorderColorProperty.PropertyName)
|
||||||
|
{
|
||||||
|
SetBorder(view);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetBorder( ExtendedPicker view )
|
||||||
|
{
|
||||||
|
if(view.HasOnlyBottomBorder)
|
||||||
|
{
|
||||||
|
var borderLayer = new CALayer();
|
||||||
|
borderLayer.MasksToBounds = true;
|
||||||
|
borderLayer.Frame = new CGRect( 0f, Frame.Height / 2, Frame.Width * 2, 1f );
|
||||||
|
borderLayer.BorderColor = view.BottomBorderColor.ToCGColor();
|
||||||
|
borderLayer.BorderWidth = 1f;
|
||||||
|
|
||||||
|
Control.Layer.AddSublayer( borderLayer );
|
||||||
|
Control.BorderStyle = UITextBorderStyle.None;
|
||||||
|
}
|
||||||
|
else if(view.HasBorder)
|
||||||
|
{
|
||||||
|
Control.BorderStyle = UITextBorderStyle.RoundedRect;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Control.BorderStyle = UITextBorderStyle.None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -101,6 +101,7 @@
|
|||||||
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
|
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="Controls\ExtendedPickerRenderer.cs" />
|
||||||
<Compile Include="Controls\ExtendedEntryRenderer.cs" />
|
<Compile Include="Controls\ExtendedEntryRenderer.cs" />
|
||||||
<Compile Include="Controls\ExtendedTabbedPageRenderer.cs" />
|
<Compile Include="Controls\ExtendedTabbedPageRenderer.cs" />
|
||||||
<Compile Include="Services\ClipboardService.cs" />
|
<Compile Include="Services\ClipboardService.cs" />
|
||||||
|
Loading…
Reference in New Issue
Block a user