1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-31 15:43:19 +00:00

Net 7 platforms migration initial

This commit is contained in:
Federico Maccaroni
2023-07-28 16:23:14 -03:00
parent 0271a4db4c
commit ef78491848
13 changed files with 420 additions and 335 deletions

View File

@@ -1,12 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net7.0-android</TargetFrameworks>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{304400AF-F0ED-40FA-B102-EA3C3EC43E4F}</ProjectGuid>
<ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<TemplateGuid>{c9e5eea5-ca05-42a1-839b-61506e0a37df}</TemplateGuid>
<OutputType>Library</OutputType>
<OutputType>Exe</OutputType>
<RootNamespace>Bit.Droid</RootNamespace>
<AssemblyName>BitwardenAndroid</AssemblyName>
<AndroidApplication>True</AndroidApplication>
@@ -15,10 +16,13 @@
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
<TargetFrameworkVersion>v13.0</TargetFrameworkVersion>
<AndroidHttpClientHandlerType>Xamarin.Android.Net.AndroidClientHandler</AndroidHttpClientHandlerType>
<SupportedOSPlatformVersion>21</SupportedOSPlatformVersion>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<Configurations>Debug;Release;FDroid</Configurations>
<JavaMaximumHeapSize>1G</JavaMaximumHeapSize>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -62,39 +66,46 @@
<AndroidEnableProfiledAot>true</AndroidEnableProfiledAot>
</PropertyGroup>
<ItemGroup>
<Reference Include="Mono.Android" />
<!--<Reference Include="Mono.Android" />
<Reference Include="Mono.Android.Export" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml" />-->
<Reference Include="System.Net.Http" Condition="'$(Configuration)'=='FDroid'" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Plugin.CurrentActivity">
<Version>2.1.0.4</Version>
<PackageReference Include="Plugin.CurrentActivity" Version="2.1.0.4">
</PackageReference>
<PackageReference Include="Portable.BouncyCastle">
<Version>1.9.0</Version>
<PackageReference Include="Portable.BouncyCastle" Version="1.9.0">
</PackageReference>
<PackageReference Include="Xamarin.AndroidX.AppCompat" Version="1.5.1.1" />
<!--<PackageReference Include="Xamarin.AndroidX.AppCompat" Version="1.5.1.1" />
<PackageReference Include="Xamarin.AndroidX.AutoFill" Version="1.1.0.16" />
<PackageReference Include="Xamarin.AndroidX.CardView" Version="1.0.0.19" />
<PackageReference Include="Xamarin.AndroidX.Core" Version="1.10.0" />
<PackageReference Include="Xamarin.AndroidX.MediaRouter" Version="1.3.1.1" />
<PackageReference Include="Xamarin.Essentials">
<Version>1.7.5</Version>
<PackageReference Include="Xamarin.Essentials" Version="1.7.5">
</PackageReference>
<PackageReference Include="Xamarin.Firebase.Messaging">
<Version>123.1.1.1</Version>
<PackageReference Include="Xamarin.Firebase.Messaging" Version="123.1.1.1">
</PackageReference>
<PackageReference Include="Xamarin.Google.Android.Material" Version="1.8.0" />
<PackageReference Include="Xamarin.Google.Dagger" Version="2.44.2.1" />
<PackageReference Include="Xamarin.GooglePlayServices.SafetyNet">
<Version>118.0.1.3</Version>
</PackageReference>
<PackageReference Include="Xamarin.GooglePlayServices.SafetyNet" Version="118.0.1.3">
</PackageReference>-->
<!--<PackageReference Include="Xamarin.AndroidX.RecyclerView" Version="1.3.0.3" />
<PackageReference Include="Xamarin.AndroidX.MediaRouter" Version="1.4.0.2" />
<PackageReference Include="Xamarin.GooglePlayServices.SafetyNet" Version="118.0.1.5" />
<PackageReference Include="Xamarin.Kotlin.StdLib.Jdk8" Version="1.9.0.1" />
<PackageReference Include="Xamarin.Kotlin.StdLib" Version="1.9.0.1" />
<PackageReference Include="Xamarin.AndroidX.Activity.Ktx" Version="1.7.2.1" />-->
<PackageReference Include="Xamarin.AndroidX.AutoFill" Version="1.1.0.18" />
<PackageReference Include="Xamarin.AndroidX.Core" Version="1.10.1.2" />
<PackageReference Include="Xamarin.AndroidX.AppCompat" Version="1.6.1.3" />
</ItemGroup>
<ItemGroup>
<!--<ItemGroup>
<Compile Include="Accessibility\AccessibilityActivity.cs" />
<Compile Include="Accessibility\AccessibilityHelpers.cs" />
<Compile Include="Accessibility\Credentials.cs" />
@@ -160,7 +171,7 @@
<Compile Include="Effects\RemoveFontPaddingEffect.cs" />
<Compile Include="Services\WatchDeviceService.cs" />
<Compile Include="Renderers\CustomLabelRenderer.cs" />
</ItemGroup>
</ItemGroup>-->
<ItemGroup>
<AndroidAsset Include="Assets\bwi-font.ttf" />
<AndroidAsset Include="Assets\RobotoMono_Regular.ttf" />
@@ -251,12 +262,10 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\App\App.csproj">
<Project>{EE44C6A1-2A85-45FE-8D9B-BF1D5F88809C}</Project>
<Name>App</Name>
<ReferenceSourceTarget></ReferenceSourceTarget>
</ProjectReference>
<ProjectReference Include="..\Core\Core.csproj">
<Project>{4b8a8c41-9820-4341-974c-41e65b7f4366}</Project>
<Name>Core</Name>
<ReferenceSourceTarget></ReferenceSourceTarget>
</ProjectReference>
</ItemGroup>
<ItemGroup>
@@ -315,5 +324,12 @@
<Folder Include="Resources\drawable-v26\" />
<Folder Include="Resources\drawable-night-v26\" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
<Target BeforeTargets="_CheckForTransitiveWindowsDesktopDependencies" Name="_FixSdkError_NETSDK1136">
<ItemGroup>
<TransitiveFrameworkReference Remove="Microsoft.WindowsDesktop.App" />
<TransitiveFrameworkReference Remove="Microsoft.WindowsDesktop.App.WPF" />
<TransitiveFrameworkReference Remove="Microsoft.WindowsDesktop.App.WindowsForms" />
</ItemGroup>
</Target>
<!--<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />-->
</Project>

View File

@@ -22,9 +22,9 @@ using Bit.App.Pages;
using Bit.App.Utilities.AccountManagement;
using Bit.App.Controls;
using Bit.Core.Enums;
#if !FDROID
using Android.Gms.Security;
#endif
//#if !FDROID
//using Android.Gms.Security;
//#endif
namespace Bit.Droid
{
@@ -37,7 +37,7 @@ namespace Bit.Droid
#if FDROID
public class MainApplication : Application
#else
public class MainApplication : Application, ProviderInstaller.IProviderInstallListener
public class MainApplication : Application //, ProviderInstaller.IProviderInstallListener
#endif
{
public MainApplication(IntPtr handle, JniHandleOwnership transer)
@@ -86,12 +86,12 @@ namespace Bit.Droid
ServiceContainer.Resolve<IConditionedAwaiterManager>());
ServiceContainer.Register<IAccountsManager>("accountsManager", accountsManager);
}
#if !FDROID
if (Build.VERSION.SdkInt <= BuildVersionCodes.Kitkat)
{
ProviderInstaller.InstallIfNeededAsync(ApplicationContext, this);
}
#endif
//#if !FDROID
// if (Build.VERSION.SdkInt <= BuildVersionCodes.Kitkat)
// {
// ProviderInstaller.InstallIfNeededAsync(ApplicationContext, this);
// }
//#endif
}
public override void OnCreate()

View File

@@ -1,60 +1,60 @@
#if !FDROID
using System;
using Android.App;
using Bit.App.Abstractions;
using Bit.Core.Abstractions;
using Bit.Core.Services;
using Bit.Core.Utilities;
using Firebase.Messaging;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Xamarin.Forms;
//#if !FDROID
//using System;
//using Android.App;
//using Bit.App.Abstractions;
//using Bit.Core.Abstractions;
//using Bit.Core.Services;
//using Bit.Core.Utilities;
//using Firebase.Messaging;
//using Newtonsoft.Json;
//using Newtonsoft.Json.Linq;
//using Xamarin.Forms;
namespace Bit.Droid.Push
{
[Service(Exported=false)]
[IntentFilter(new[] { "com.google.firebase.MESSAGING_EVENT" })]
public class FirebaseMessagingService : Firebase.Messaging.FirebaseMessagingService
{
public async override void OnNewToken(string token)
{
try {
var stateService = ServiceContainer.Resolve<IStateService>("stateService");
var pushNotificationService = ServiceContainer.Resolve<IPushNotificationService>("pushNotificationService");
//namespace Bit.Droid.Push
//{
// [Service(Exported=false)]
// [IntentFilter(new[] { "com.google.firebase.MESSAGING_EVENT" })]
// public class FirebaseMessagingService : Firebase.Messaging.FirebaseMessagingService
// {
// public async override void OnNewToken(string token)
// {
// try {
// var stateService = ServiceContainer.Resolve<IStateService>("stateService");
// var pushNotificationService = ServiceContainer.Resolve<IPushNotificationService>("pushNotificationService");
await stateService.SetPushRegisteredTokenAsync(token);
await pushNotificationService.RegisterAsync();
}
catch (Exception ex)
{
Logger.Instance.Exception(ex);
}
}
// await stateService.SetPushRegisteredTokenAsync(token);
// await pushNotificationService.RegisterAsync();
// }
// catch (Exception ex)
// {
// Logger.Instance.Exception(ex);
// }
// }
public async override void OnMessageReceived(RemoteMessage message)
{
try
{
if (message?.Data == null)
{
return;
}
var data = message.Data.ContainsKey("data") ? message.Data["data"] : null;
if (data == null)
{
return;
}
// public async override void OnMessageReceived(RemoteMessage message)
// {
// try
// {
// if (message?.Data == null)
// {
// return;
// }
// var data = message.Data.ContainsKey("data") ? message.Data["data"] : null;
// if (data == null)
// {
// return;
// }
var obj = JObject.Parse(data);
var listener = ServiceContainer.Resolve<IPushNotificationListenerService>(
"pushNotificationListenerService");
await listener.OnMessageAsync(obj, Device.Android);
}
catch (Exception ex)
{
Logger.Instance.Exception(ex);
}
}
}
}
#endif
// var obj = JObject.Parse(data);
// var listener = ServiceContainer.Resolve<IPushNotificationListenerService>(
// "pushNotificationListenerService");
// await listener.OnMessageAsync(obj, Device.Android);
// }
// catch (Exception ex)
// {
// Logger.Instance.Exception(ex);
// }
// }
// }
//}
//#endif

View File

@@ -0,0 +1,5 @@
<resources>
<declare-styleable name='SKCanvasView'>
<attr name='ignorePixelScaling' format='boolean'/>
</declare-styleable>
</resources>