1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-11-27 12:26:31 +01:00

Project lib updates and migration (#789)

* Replace 3rd party FAB lib with our own code

* merged

* merged

* WIP

* WIP

* WIP

* WIP

* Updated LiteDB

* Update ZXing libs to 2.4.1

* Missing semicolon

* rename fab style to btn-fab

* Revert project guid modified by VSmac
This commit is contained in:
Matt Portune 2020-03-20 17:54:23 -04:00 committed by GitHub
parent 6fdb1e3356
commit 145482ea30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
28 changed files with 125 additions and 114 deletions

View File

@ -15,11 +15,11 @@
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
<AndroidUseLatestPlatformSdk>false</AndroidUseLatestPlatformSdk>
<TargetFrameworkVersion>v10.0</TargetFrameworkVersion>
<AndroidHttpClientHandlerType>Xamarin.Android.Net.AndroidClientHandler</AndroidHttpClientHandlerType>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<AndroidLinkSkip>Xamarin.GooglePlayServices.Base;Xamarin.GooglePlayServices.Basement;Xamarin.GooglePlayServices.Measurement;Xamarin.GooglePlayServices.Gcm;BitwardenAndroid;BitwardenApp;BitwardenCore;Xamarin.Android.Net;Xamarin.Android.Net.OldAndroidSSLSocketFactory</AndroidLinkSkip>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@ -30,10 +30,8 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>3</WarningLevel>
<AndroidLinkMode>None</AndroidLinkMode>
<AndroidEnableMultiDex>true</AndroidEnableMultiDex>
<AndroidSupportedAbis />
<JavaMaximumHeapSize>1G</JavaMaximumHeapSize>
<AndroidLinkSkip>Xamarin.GooglePlayServices.Base;Xamarin.GooglePlayServices.Basement;Xamarin.GooglePlayServices.Measurement;Xamarin.GooglePlayServices.Gcm;BitwardenAndroid;BitwardenApp;BitwardenCore;Xamarin.Android.Net;Xamarin.Android.Net.OldAndroidSSLSocketFactory</AndroidLinkSkip>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugSymbols>false</DebugSymbols>
@ -46,8 +44,6 @@
<AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
<AndroidSupportedAbis>armeabi-v7a;x86;x86_64;arm64-v8a</AndroidSupportedAbis>
<JavaMaximumHeapSize>1G</JavaMaximumHeapSize>
<AndroidEnableMultiDex>true</AndroidEnableMultiDex>
<AndroidLinkSkip>Xamarin.GooglePlayServices.Base;Xamarin.GooglePlayServices.Basement;Xamarin.GooglePlayServices.Measurement;Xamarin.GooglePlayServices.Gcm;BitwardenAndroid;BitwardenApp;BitwardenCore;Xamarin.Android.Net;Xamarin.Android.Net.OldAndroidSSLSocketFactory</AndroidLinkSkip>
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
<AndroidLinkMode>Full</AndroidLinkMode>
</PropertyGroup>
@ -63,10 +59,8 @@
<DefineConstants>FDROID</DefineConstants>
<AndroidSupportedAbis>armeabi-v7a;x86;x86_64;arm64-v8a</AndroidSupportedAbis>
<JavaMaximumHeapSize>1G</JavaMaximumHeapSize>
<AndroidEnableMultiDex>true</AndroidEnableMultiDex>
<AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
<AndroidLinkSkip>Xamarin.GooglePlayServices.Base;Xamarin.GooglePlayServices.Basement;Xamarin.GooglePlayServices.Measurement;Xamarin.GooglePlayServices.Gcm;BitwardenAndroid;BitwardenApp;BitwardenCore;Xamarin.Android.Net;Xamarin.Android.Net.OldAndroidSSLSocketFactory</AndroidLinkSkip>
<AndroidLinkMode>Full</AndroidLinkMode>
</PropertyGroup>
<ItemGroup>
@ -82,21 +76,22 @@
<Version>2.1.0.4</Version>
</PackageReference>
<PackageReference Include="Portable.BouncyCastle">
<Version>1.8.5.2</Version>
<Version>1.8.6</Version>
</PackageReference>
<PackageReference Include="Xamarin.Essentials">
<Version>1.3.1</Version>
<Version>1.5.1</Version>
</PackageReference>
<PackageReference Include="Xamarin.Firebase.Messaging">
<Version>60.1142.1</Version>
<Version>71.1740.0</Version>
</PackageReference>
<PackageReference Include="Xamarin.Android.Support.Design" Version="28.0.0.3" />
<PackageReference Include="Xamarin.Android.Support.v7.AppCompat" Version="28.0.0.3" />
<PackageReference Include="Xamarin.Android.Support.v4" Version="28.0.0.3" />
<PackageReference Include="Xamarin.Android.Support.v7.CardView" Version="28.0.0.3" />
<PackageReference Include="Xamarin.Android.Support.v7.MediaRouter" Version="28.0.0.3" />
<PackageReference Include="Xamarin.Google.Android.Material" Version="1.0.0" />
<PackageReference Include="Xamarin.AndroidX.AppCompat" Version="1.1.0" />
<PackageReference Include="Xamarin.AndroidX.Legacy.Support.V4" Version="1.0.0" />
<PackageReference Include="Xamarin.AndroidX.CardView" Version="1.0.0" />
<PackageReference Include="Xamarin.AndroidX.MediaRouter" Version="1.1.0" />
<PackageReference Include="Xamarin.AndroidX.Migration" Version="1.0.1" />
<PackageReference Include="Xamarin.GooglePlayServices.SafetyNet">
<Version>60.1142.1</Version>
<Version>71.1600.0</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
@ -113,6 +108,7 @@
<Compile Include="Autofill\FilledItem.cs" />
<Compile Include="Autofill\Parser.cs" />
<Compile Include="Autofill\SavedItem.cs" />
<Compile Include="Effects\FabShadowEffect.cs" />
<Compile Include="Effects\FixedSizeEffect.cs" />
<Compile Include="Effects\SelectableLabelEffect.cs" />
<Compile Include="Effects\TabBarEffect.cs" />
@ -143,7 +139,6 @@
<Compile Include="Tiles\GeneratorTileService.cs" />
<Compile Include="Tiles\MyVaultTileService.cs" />
<Compile Include="Utilities\AndroidHelpers.cs" />
<Compile Include="Utilities\CustomFingerprintDialogFragment.cs" />
<Compile Include="Utilities\HockeyAppCrashManagerListener.cs" />
<Compile Include="Utilities\StaticStore.cs" />
</ItemGroup>

View File

@ -0,0 +1,29 @@
using Android.Graphics.Drawables;
using Bit.Droid.Effects;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
[assembly: ExportEffect(typeof(FabShadowEffect), "FabShadowEffect")]
namespace Bit.Droid.Effects
{
public class FabShadowEffect : PlatformEffect
{
protected override void OnAttached ()
{
if(Control is Android.Widget.Button button)
{
var gd = new GradientDrawable();
gd.SetColor(((Color)Application.Current.Resources["FabColor"]).ToAndroid());
gd.SetCornerRadius(100);
button.SetBackground(gd);
button.Elevation = 6;
button.TranslationZ = 20;
}
}
protected override void OnDetached ()
{
}
}
}

View File

@ -1,7 +1,4 @@
using Android.Support.Design.BottomNavigation;
using Android.Support.Design.Widget;
using Android.Views;
using Android.Widget;
using Android.Widget;
using Bit.Droid.Effects;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;

View File

@ -1,7 +1,4 @@
using Android.Support.Design.BottomNavigation;
using Android.Support.Design.Widget;
using Android.Views;
using Android.Widget;
using Android.Widget;
using Bit.Droid.Effects;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;

View File

@ -1,7 +1,6 @@
using Android.Support.Design.BottomNavigation;
using Android.Support.Design.Widget;
using Android.Views;
using Android.Views;
using Bit.Droid.Effects;
using Google.Android.Material.BottomNavigation;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;

View File

@ -17,7 +17,7 @@ using Bit.Core.Enums;
using Android.Nfc;
using Bit.App.Utilities;
using System.Threading.Tasks;
using Android.Support.V4.Content;
using AndroidX.Core.Content;
namespace Bit.Droid
{

View File

@ -70,7 +70,6 @@ namespace Bit.Droid
{
ServiceContainer.Register<ILogService>("logService", new AndroidLogService());
Refractored.FabControl.Droid.FloatingActionButtonViewRenderer.Init();
// Note: This might cause a race condition. Investigate more.
Task.Run(() =>
{
@ -83,7 +82,6 @@ namespace Bit.Droid
ZXing.Net.Mobile.Forms.Android.Platform.Init();
});
CrossFingerprint.SetCurrentActivityResolver(() => CrossCurrentActivity.Current.Activity);
CrossFingerprint.SetDialogFragmentType<CustomFingerprintDialogFragment>();
var preferencesStorage = new PreferencesStorageService(null);
var documentsPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);

View File

@ -6,7 +6,7 @@
android:versionName="2.3.1"
package="com.x8bit.bitwarden">
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="29" />
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="29" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.NFC" />
@ -30,7 +30,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:networkSecurityConfig="@xml/network_security_config">
<provider
android:name="android.support.v4.content.FileProvider"
android:name="androidx.core.content.FileProvider"
android:authorities="com.x8bit.bitwarden.fileprovider"
android:exported="false"
android:grantUriPermissions="true">

View File

@ -1,6 +1,6 @@
using Android.Content;
using Android.Graphics.Drawables;
using Android.Support.V4.Content.Res;
using AndroidX.Core.Content.Resources;
using Bit.App.Controls;
using Bit.Droid.Renderers;
using Xamarin.Forms;

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.TabLayout xmlns:android="http://schemas.android.com/apk/res/android"
<com.google.android.material.tabs.TabLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/sliding_tabs"
android:layout_width="match_parent"

View File

@ -1,4 +1,4 @@
<android.support.v7.widget.Toolbar
<androidx.appcompat.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toolbar"
android:layout_width="match_parent"

View File

@ -14,14 +14,14 @@ using Android.Nfc;
using Android.OS;
using Android.Provider;
using Android.Runtime;
using Android.Support.V4.App;
using Android.Support.V4.Content;
using Android.Text;
using Android.Text.Method;
using Android.Views.Autofill;
using Android.Views.InputMethods;
using Android.Webkit;
using Android.Widget;
using AndroidX.Core.App;
using AndroidX.Core.Content;
using Bit.App.Abstractions;
using Bit.App.Resources;
using Bit.Core;

View File

@ -1,30 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Plugin.Fingerprint.Dialog;
using Xamarin.Forms.Platform.Android;
namespace Bit.Droid.Utilities
{
public class CustomFingerprintDialogFragment : FingerprintDialogFragment
{
public CustomFingerprintDialogFragment()
: base()
{
DefaultColor = ((Xamarin.Forms.Color)Xamarin.Forms.Application.Current.Resources["MutedColor"])
.ToAndroid();
NegativeColor = ((Xamarin.Forms.Color)Xamarin.Forms.Application.Current.Resources["DangerColor"])
.ToAndroid();
PositiveColor = ((Xamarin.Forms.Color)Xamarin.Forms.Application.Current.Resources["SuccessColor"])
.ToAndroid();
}
}
}

View File

@ -14,12 +14,12 @@
<ItemGroup>
<PackageReference Include="HockeySDK.Xamarin" Version="5.2.0" />
<PackageReference Include="Plugin.Fingerprint" Version="1.4.9" />
<PackageReference Include="Refractored.FloatingActionButtonForms" Version="2.1.0" />
<PackageReference Include="Xamarin.Essentials" Version="1.3.1" />
<PackageReference Include="Plugin.Fingerprint" Version="2.1.1" />
<PackageReference Include="Xamarin.Essentials" Version="1.5.1" />
<PackageReference Include="Xamarin.FFImageLoading.Forms" Version="2.4.11.982" />
<PackageReference Include="Xamarin.Forms" Version="4.4.0.991265" />
<PackageReference Include="ZXing.Net.Mobile.Forms" Version="2.1.47" />
<PackageReference Include="Xamarin.Forms" Version="4.5.0.356" />
<PackageReference Include="ZXing.Net.Mobile" Version="2.4.1" />
<PackageReference Include="ZXing.Net.Mobile.Forms" Version="2.4.1" />
</ItemGroup>
<ItemGroup>

View File

@ -0,0 +1,11 @@
using Xamarin.Forms;
namespace Bit.App.Effects
{
public class FabShadowEffect : RoutingEffect
{
public FabShadowEffect()
: base("Bitwarden.FabShadowEffect")
{ }
}
}

View File

@ -7,7 +7,7 @@
xmlns:controls="clr-namespace:Bit.App.Controls"
xmlns:u="clr-namespace:Bit.App.Utilities"
xmlns:views="clr-namespace:Bit.Core.Models.View;assembly=BitwardenCore"
xmlns:fab="clr-namespace:Refractored.FabControl;assembly=Refractored.FabControl"
xmlns:effects="clr-namespace:Bit.App.Effects;assembly=BitwardenApp"
x:DataType="pages:FoldersPageViewModel"
x:Name="_page"
Title="{Binding PageTitle}">
@ -66,14 +66,19 @@
AbsoluteLayout.LayoutFlags="All"
AbsoluteLayout.LayoutBounds="0, 0, 1, 1">
</ContentView>
<fab:FloatingActionButtonView
<Button
x:Name="_fab"
ImageName="plus.png"
Image="plus.png"
Clicked="AddButton_Clicked"
Style="{StaticResource btn-fab}"
AbsoluteLayout.LayoutFlags="PositionProportional"
AbsoluteLayout.LayoutBounds="1, 1, AutoSize, AutoSize"
AutomationProperties.IsInAccessibleTree="True"
AutomationProperties.Name="{u:I18n AddFolder}">
</fab:FloatingActionButtonView>
<Button.Effects>
<effects:FabShadowEffect />
</Button.Effects>
</Button>
</AbsoluteLayout>
</pages:BaseContentPage>

View File

@ -21,10 +21,6 @@ namespace Bit.App.Pages
ToolbarItems.Add(_closeItem);
ToolbarItems.Add(_addItem);
}
else
{
_fab.Clicked = AddButton_Clicked;
}
}
protected override async void OnAppearing()

View File

@ -5,7 +5,7 @@
xmlns:pages="clr-namespace:Bit.App.Pages"
xmlns:u="clr-namespace:Bit.App.Utilities"
xmlns:controls="clr-namespace:Bit.App.Controls"
xmlns:fab="clr-namespace:Refractored.FabControl;assembly=Refractored.FabControl"
xmlns:effects="clr-namespace:Bit.App.Effects;assembly=BitwardenApp"
x:DataType="pages:AutofillCiphersPageViewModel"
Title="{Binding PageTitle}"
x:Name="_page">
@ -94,12 +94,16 @@
AbsoluteLayout.LayoutFlags="All"
AbsoluteLayout.LayoutBounds="0, 0, 1, 1">
</ContentView>
<fab:FloatingActionButtonView
<Button
x:Name="_fab"
ImageName="plus.png"
Clicked="AddButton_Clicked"
Style="{StaticResource btn-fab}"
AbsoluteLayout.LayoutFlags="PositionProportional"
AbsoluteLayout.LayoutBounds="1, 1, AutoSize, AutoSize">
</fab:FloatingActionButtonView>
<Button.Effects>
<effects:FabShadowEffect />
</Button.Effects>
</Button>
</AbsoluteLayout>
</pages:BaseContentPage>

View File

@ -22,7 +22,6 @@ namespace Bit.App.Pages
InitializeComponent();
_vm = BindingContext as AutofillCiphersPageViewModel;
_vm.Page = this;
_fab.Clicked = AddButton_Clicked;
_vm.Init(appOptions);
_platformUtilsService = ServiceContainer.Resolve<IPlatformUtilsService>("platformUtilsService");

View File

@ -6,7 +6,6 @@
xmlns:u="clr-namespace:Bit.App.Utilities"
xmlns:effects="clr-namespace:Bit.App.Effects"
xmlns:controls="clr-namespace:Bit.App.Controls"
xmlns:fab="clr-namespace:Refractored.FabControl;assembly=Refractored.FabControl"
x:DataType="pages:GroupingsPageViewModel"
Title="{Binding PageTitle}"
x:Name="_page">
@ -144,14 +143,19 @@
AbsoluteLayout.LayoutFlags="All"
AbsoluteLayout.LayoutBounds="0, 0, 1, 1">
</ContentView>
<fab:FloatingActionButtonView
<Button
x:Name="_fab"
ImageName="plus.png"
Image="plus.png"
Clicked="AddButton_Clicked"
Style="{StaticResource btn-fab}"
AbsoluteLayout.LayoutFlags="PositionProportional"
AbsoluteLayout.LayoutBounds="1, 1, AutoSize, AutoSize"
AutomationProperties.IsInAccessibleTree="True"
AutomationProperties.Name="{u:I18n AddItem}">
</fab:FloatingActionButtonView>
<Button.Effects>
<effects:FabShadowEffect />
</Button.Effects>
</Button>
</AbsoluteLayout>
</pages:BaseContentPage>

View File

@ -60,7 +60,6 @@ namespace Bit.App.Pages
}
else
{
_fab.Clicked = AddButton_Clicked;
ToolbarItems.Add(_syncItem);
ToolbarItems.Add(_lockItem);
ToolbarItems.Add(_exitItem);

View File

@ -7,7 +7,6 @@
xmlns:u="clr-namespace:Bit.App.Utilities"
xmlns:controls="clr-namespace:Bit.App.Controls"
xmlns:effects="clr-namespace:Bit.App.Effects"
xmlns:fab="clr-namespace:Refractored.FabControl;assembly=Refractored.FabControl"
xmlns:views="clr-namespace:Bit.Core.Models.View;assembly=BitwardenCore"
x:DataType="pages:ViewPageViewModel"
x:Name="_page"
@ -663,14 +662,19 @@
AbsoluteLayout.LayoutFlags="All"
AbsoluteLayout.LayoutBounds="0, 0, 1, 1">
</ContentView>
<fab:FloatingActionButtonView
<Button
x:Name="_fab"
ImageName="pencil.png"
Image="pencil.png"
Clicked="EditButton_Clicked"
Style="{StaticResource btn-fab}"
AbsoluteLayout.LayoutFlags="PositionProportional"
AbsoluteLayout.LayoutBounds="1, 1, AutoSize, AutoSize"
AutomationProperties.IsInAccessibleTree="True"
AutomationProperties.Name="{u:I18n EditItem}">
</fab:FloatingActionButtonView>
<Button.Effects>
<effects:FabShadowEffect />
</Button.Effects>
</Button>
</AbsoluteLayout>
</pages:BaseContentPage>

View File

@ -33,7 +33,6 @@ namespace Bit.App.Pages
}
else
{
_fab.Clicked = EditButton_Clicked;
_mainLayout.Padding = new Thickness(0, 0, 0, 75);
ToolbarItems.Add(_attachmentsItem);
ToolbarItems.Add(_deleteItem);

View File

@ -218,7 +218,7 @@ namespace Bit.App.Services
var supportsFace = await _deviceActionService.SupportsFaceBiometricAsync();
text = supportsFace ? AppResources.FaceIDDirection : AppResources.FingerprintDirection;
}
var fingerprintRequest = new AuthenticationRequestConfiguration(text)
var fingerprintRequest = new AuthenticationRequestConfiguration(text, text)
{
CancelTitle = AppResources.Cancel,
FallbackTitle = fallbackText

View File

@ -1,8 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<ResourceDictionary xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Bit.App.Styles.Base"
xmlns:fab="clr-namespace:Refractored.FabControl;assembly=Refractored.FabControl">
x:Class="Bit.App.Styles.Base">
<!-- General -->
<Style TargetType="Label"
@ -97,13 +96,19 @@
<Setter Property="TextColor"
Value="{StaticResource DisabledIconColor}" />
</Style>
<Style TargetType="fab:FloatingActionButtonView">
<Setter Property="ColorNormal"
Value="{StaticResource FabColor}" />
<Setter Property="ColorPressed"
Value="{StaticResource FabPressedColor}" />
<Setter Property="ColorRipple"
Value="{StaticResource FabPressedColor}" />
<Style x:Key="btn-fab" TargetType="Button">
<Setter Property="HeightRequest"
Value="56" />
<Setter Property="WidthRequest"
Value="56" />
<Setter Property="HorizontalOptions"
Value="CenterAndExpand" />
<Setter Property="VerticalOptions"
Value="CenterAndExpand" />
<Setter Property="Padding"
Value="16" />
<Setter Property="Margin"
Value="16" />
</Style>
<!-- Title -->

View File

@ -24,7 +24,7 @@
<ItemGroup>
<PackageReference Include="CsvHelper" Version="15.0.1" />
<PackageReference Include="LiteDB" Version="4.1.4" />
<PackageReference Include="LiteDB" Version="5.0.4" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="PCLCrypto" Version="2.0.147" />
</ItemGroup>

View File

@ -14,7 +14,7 @@ namespace Bit.Core.Services
ContractResolver = new CamelCasePropertyNamesContractResolver()
};
private readonly string _dbPath;
private LiteCollection<JsonItem> _collection;
private ILiteCollection<JsonItem> _collection;
private Task _initTask;
public LiteDbStorageService(string dbPath)
@ -36,7 +36,7 @@ namespace Bit.Core.Services
{
try
{
var db = new LiteDatabase($"Filename={_dbPath};");
var db = new LiteDatabase($"Filename={_dbPath};Upgrade=true;");
_collection = db.GetCollection<JsonItem>("json_items");
}
finally
@ -68,7 +68,7 @@ namespace Bit.Core.Services
public async Task RemoveAsync(string key)
{
await InitAsync();
_collection.Delete(i => i.Id == key);
_collection.DeleteMany(i => i.Id == key);
}
private class JsonItem

View File

@ -168,7 +168,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Xamarin.Essentials">
<Version>1.3.1</Version>
<Version>1.5.1</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />