mirror of
https://github.com/bitwarden/mobile.git
synced 2024-11-07 09:20:04 +01:00
Merge branch 'feature/maui-migration' into feature/maui-migration-ios-ext-tap-workaround
This commit is contained in:
commit
15a306490d
@ -115,7 +115,6 @@
|
||||
<Folder Include="Platforms\Android\Utilities\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">
|
||||
<PackageReference Include="Plugin.CurrentActivity" Version="2.1.0.4" />
|
||||
<PackageReference Include="Xamarin.AndroidX.AutoFill" Version="1.1.0.18" />
|
||||
<PackageReference Include="Xamarin.AndroidX.Activity.Ktx" Version="1.7.2.1" />
|
||||
</ItemGroup>
|
||||
|
@ -12,7 +12,6 @@ using Bit.Core.Abstractions;
|
||||
using Bit.Core.Services;
|
||||
using Bit.Core.Utilities;
|
||||
using Bit.Droid.Services;
|
||||
using Plugin.CurrentActivity;
|
||||
using Plugin.Fingerprint;
|
||||
using Xamarin.Android.Net;
|
||||
using System.Net.Http;
|
||||
@ -101,7 +100,6 @@ namespace Bit.Droid
|
||||
{
|
||||
base.OnCreate();
|
||||
Bootstrap();
|
||||
CrossCurrentActivity.Current.Init(this);
|
||||
}
|
||||
|
||||
public void OnProviderInstallFailed(int errorCode, Intent recoveryIntent)
|
||||
@ -136,7 +134,7 @@ namespace Bit.Droid
|
||||
// });
|
||||
// ZXing.Net.Mobile.Forms.Android.Platform.Init();
|
||||
//});
|
||||
CrossFingerprint.SetCurrentActivityResolver(() => CrossCurrentActivity.Current.Activity);
|
||||
CrossFingerprint.SetCurrentActivityResolver(() => Microsoft.Maui.ApplicationModel.Platform.CurrentActivity);
|
||||
|
||||
var preferencesStorage = new PreferencesStorageService(null);
|
||||
var localAppDataFolderPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData);
|
||||
|
@ -12,7 +12,6 @@ using Bit.Core.Enums;
|
||||
using Bit.Core.Models.View;
|
||||
using Bit.Core.Utilities;
|
||||
using Bit.Droid.Autofill;
|
||||
using Plugin.CurrentActivity;
|
||||
using Application = Android.App.Application;
|
||||
|
||||
namespace Bit.Droid.Services
|
||||
@ -46,7 +45,7 @@ namespace Bit.Droid.Services
|
||||
}
|
||||
try
|
||||
{
|
||||
var activity = (MainActivity)CrossCurrentActivity.Current.Activity;
|
||||
var activity = (MainActivity)Microsoft.Maui.ApplicationModel.Platform.CurrentActivity;
|
||||
var afm = (AutofillManager)activity.GetSystemService(
|
||||
Java.Lang.Class.FromType(typeof(AutofillManager)));
|
||||
return afm.IsEnabled && afm.HasEnabledAutofillServices;
|
||||
@ -65,7 +64,7 @@ namespace Bit.Droid.Services
|
||||
}
|
||||
try
|
||||
{
|
||||
var activity = (MainActivity)CrossCurrentActivity.Current.Activity;
|
||||
var activity = (MainActivity)Microsoft.Maui.ApplicationModel.Platform.CurrentActivity;
|
||||
var type = Java.Lang.Class.FromType(typeof(AutofillManager));
|
||||
var manager = activity.GetSystemService(type) as AutofillManager;
|
||||
return manager.IsAutofillSupported;
|
||||
@ -78,7 +77,7 @@ namespace Bit.Droid.Services
|
||||
|
||||
public void Autofill(CipherView cipher)
|
||||
{
|
||||
var activity = CrossCurrentActivity.Current.Activity as MauiAppCompatActivity;
|
||||
var activity = Microsoft.Maui.ApplicationModel.Platform.CurrentActivity as MauiAppCompatActivity;
|
||||
if (activity == null)
|
||||
{
|
||||
return;
|
||||
@ -170,7 +169,7 @@ namespace Bit.Droid.Services
|
||||
{
|
||||
try
|
||||
{
|
||||
var activity = (MainActivity)CrossCurrentActivity.Current.Activity;
|
||||
var activity = (MainActivity)Microsoft.Maui.ApplicationModel.Platform.CurrentActivity;
|
||||
var type = Java.Lang.Class.FromType(typeof(AutofillManager));
|
||||
var manager = activity.GetSystemService(type) as AutofillManager;
|
||||
manager.DisableAutofillServices();
|
||||
|
@ -18,7 +18,6 @@ using Bit.App.Utilities.Prompts;
|
||||
using Bit.Core.Abstractions;
|
||||
using Bit.Core.Enums;
|
||||
using Bit.App.Droid.Utilities;
|
||||
using Plugin.CurrentActivity;
|
||||
using Microsoft.Maui.Controls.Compatibility.Platform.Android;
|
||||
using Resource = Bit.Core.Resource;
|
||||
using Application = Android.App.Application;
|
||||
@ -66,7 +65,7 @@ namespace Bit.Droid.Services
|
||||
_toast.Dispose();
|
||||
_toast = null;
|
||||
}
|
||||
_toast = Android.Widget.Toast.MakeText(CrossCurrentActivity.Current.Activity, text,
|
||||
_toast = Android.Widget.Toast.MakeText(Microsoft.Maui.ApplicationModel.Platform.CurrentActivity, text,
|
||||
longDuration ? ToastLength.Long : ToastLength.Short);
|
||||
_toast.Show();
|
||||
}
|
||||
@ -79,7 +78,7 @@ namespace Bit.Droid.Services
|
||||
// https://developer.android.com/reference/android/content/pm/PackageManager#getLaunchIntentSenderForPackage(java.lang.String)
|
||||
return false;
|
||||
}
|
||||
var activity = CrossCurrentActivity.Current.Activity;
|
||||
var activity = Microsoft.Maui.ApplicationModel.Platform.CurrentActivity;
|
||||
appName = appName.Replace("androidapp://", string.Empty);
|
||||
var launchIntentSender = activity?.PackageManager?.GetLaunchIntentSenderForPackage(appName);
|
||||
launchIntentSender?.SendIntent(activity, Result.Ok, null, null, null);
|
||||
@ -93,7 +92,7 @@ namespace Bit.Droid.Services
|
||||
await HideLoadingAsync();
|
||||
}
|
||||
|
||||
var activity = CrossCurrentActivity.Current.Activity;
|
||||
var activity = Microsoft.Maui.ApplicationModel.Platform.CurrentActivity;
|
||||
var inflater = (LayoutInflater)activity.GetSystemService(Context.LayoutInflaterService);
|
||||
var dialogView = inflater.Inflate(Resource.Layout.progress_dialog_layout, null);
|
||||
|
||||
@ -159,7 +158,7 @@ namespace Bit.Droid.Services
|
||||
}
|
||||
|
||||
// Finally if all else fails, let's see if current activity is MainActivity
|
||||
if (CrossCurrentActivity.Current.Activity is MainActivity activity && IsAlive(activity))
|
||||
if (Microsoft.Maui.ApplicationModel.Platform.CurrentActivity is MainActivity activity && IsAlive(activity))
|
||||
{
|
||||
activity.RunOnUiThread(actionDismiss);
|
||||
return Task.CompletedTask;
|
||||
@ -193,7 +192,7 @@ namespace Bit.Droid.Services
|
||||
string text = null, string okButtonText = null, string cancelButtonText = null,
|
||||
bool numericKeyboard = false, bool autofocus = true, bool password = false)
|
||||
{
|
||||
var activity = (MainActivity)CrossCurrentActivity.Current.Activity;
|
||||
var activity = (MainActivity)Microsoft.Maui.ApplicationModel.Platform.CurrentActivity;
|
||||
if (activity == null)
|
||||
{
|
||||
return Task.FromResult<string>(null);
|
||||
@ -250,7 +249,7 @@ namespace Bit.Droid.Services
|
||||
|
||||
public Task<ValidatablePromptResponse?> DisplayValidatablePromptAsync(ValidatablePromptConfig config)
|
||||
{
|
||||
var activity = (MainActivity)CrossCurrentActivity.Current.Activity;
|
||||
var activity = (MainActivity)Microsoft.Maui.ApplicationModel.Platform.CurrentActivity;
|
||||
if (activity == null)
|
||||
{
|
||||
return Task.FromResult<ValidatablePromptResponse?>(null);
|
||||
@ -327,7 +326,7 @@ namespace Bit.Droid.Services
|
||||
|
||||
public void RateApp()
|
||||
{
|
||||
var activity = (MainActivity)CrossCurrentActivity.Current.Activity;
|
||||
var activity = (MainActivity)Microsoft.Maui.ApplicationModel.Platform.CurrentActivity;
|
||||
try
|
||||
{
|
||||
var rateIntent = RateIntentForUrl("market://details", activity);
|
||||
@ -360,14 +359,14 @@ namespace Bit.Droid.Services
|
||||
|
||||
public bool SupportsNfc()
|
||||
{
|
||||
var activity = (MainActivity)CrossCurrentActivity.Current.Activity;
|
||||
var activity = (MainActivity)Microsoft.Maui.ApplicationModel.Platform.CurrentActivity;
|
||||
var manager = activity.GetSystemService(Context.NfcService) as NfcManager;
|
||||
return manager.DefaultAdapter?.IsEnabled ?? false;
|
||||
}
|
||||
|
||||
public bool SupportsCamera()
|
||||
{
|
||||
var activity = (MainActivity)CrossCurrentActivity.Current.Activity;
|
||||
var activity = (MainActivity)Microsoft.Maui.ApplicationModel.Platform.CurrentActivity;
|
||||
return activity.PackageManager.HasSystemFeature(PackageManager.FeatureCamera);
|
||||
}
|
||||
|
||||
@ -383,7 +382,7 @@ namespace Bit.Droid.Services
|
||||
|
||||
public Task<string> DisplayAlertAsync(string title, string message, string cancel, params string[] buttons)
|
||||
{
|
||||
var activity = (MainActivity)CrossCurrentActivity.Current.Activity;
|
||||
var activity = (MainActivity)Microsoft.Maui.ApplicationModel.Platform.CurrentActivity;
|
||||
if (activity == null)
|
||||
{
|
||||
return Task.FromResult<string>(null);
|
||||
@ -464,7 +463,7 @@ namespace Bit.Droid.Services
|
||||
|
||||
public void OpenAccessibilityOverlayPermissionSettings()
|
||||
{
|
||||
var activity = (MainActivity)CrossCurrentActivity.Current.Activity;
|
||||
var activity = (MainActivity)Microsoft.Maui.ApplicationModel.Platform.CurrentActivity;
|
||||
try
|
||||
{
|
||||
var intent = new Intent(Settings.ActionManageOverlayPermission);
|
||||
@ -495,7 +494,7 @@ namespace Bit.Droid.Services
|
||||
{
|
||||
try
|
||||
{
|
||||
var activity = (MainActivity)CrossCurrentActivity.Current.Activity;
|
||||
var activity = (MainActivity)Microsoft.Maui.ApplicationModel.Platform.CurrentActivity;
|
||||
var intent = new Intent(Settings.ActionAccessibilitySettings);
|
||||
activity.StartActivity(intent);
|
||||
}
|
||||
@ -504,7 +503,7 @@ namespace Bit.Droid.Services
|
||||
|
||||
public void OpenAutofillSettings()
|
||||
{
|
||||
var activity = (MainActivity)CrossCurrentActivity.Current.Activity;
|
||||
var activity = (MainActivity)Microsoft.Maui.ApplicationModel.Platform.CurrentActivity;
|
||||
try
|
||||
{
|
||||
var intent = new Intent(Settings.ActionRequestSetAutofillService);
|
||||
@ -535,7 +534,7 @@ namespace Bit.Droid.Services
|
||||
|
||||
public void CloseMainApp()
|
||||
{
|
||||
var activity = (MainActivity)CrossCurrentActivity.Current.Activity;
|
||||
var activity = (MainActivity)Microsoft.Maui.ApplicationModel.Platform.CurrentActivity;
|
||||
if (activity == null)
|
||||
{
|
||||
return;
|
||||
@ -574,7 +573,7 @@ namespace Bit.Droid.Services
|
||||
|
||||
public float GetSystemFontSizeScale()
|
||||
{
|
||||
var activity = CrossCurrentActivity.Current?.Activity as MainActivity;
|
||||
var activity = Microsoft.Maui.ApplicationModel.Platform.CurrentActivity as MainActivity;
|
||||
return activity?.Resources?.Configuration?.FontScale ?? 1;
|
||||
}
|
||||
|
||||
@ -585,7 +584,7 @@ namespace Bit.Droid.Services
|
||||
|
||||
public async Task SetScreenCaptureAllowedAsync()
|
||||
{
|
||||
var activity = CrossCurrentActivity.Current?.Activity;
|
||||
var activity = Microsoft.Maui.ApplicationModel.Platform.CurrentActivity;
|
||||
if (await _stateService.GetScreenCaptureAllowedAsync())
|
||||
{
|
||||
activity.RunOnUiThread(() => activity.Window.ClearFlags(WindowManagerFlags.Secure));
|
||||
|
@ -13,7 +13,6 @@ using AndroidX.Core.Content;
|
||||
using Bit.Core.Resources.Localization;
|
||||
using Bit.Core;
|
||||
using Bit.Core.Abstractions;
|
||||
using Plugin.CurrentActivity;
|
||||
using FileProvider = AndroidX.Core.Content.FileProvider;
|
||||
|
||||
namespace Bit.Droid.Services
|
||||
@ -43,7 +42,7 @@ namespace Bit.Droid.Services
|
||||
{
|
||||
try
|
||||
{
|
||||
var activity = (MainActivity)CrossCurrentActivity.Current.Activity;
|
||||
var activity = (MainActivity)Microsoft.Maui.ApplicationModel.Platform.CurrentActivity;
|
||||
var intent = BuildOpenFileIntent(fileData, fileName);
|
||||
if (intent == null)
|
||||
{
|
||||
@ -60,7 +59,7 @@ namespace Bit.Droid.Services
|
||||
{
|
||||
try
|
||||
{
|
||||
var activity = (MainActivity)CrossCurrentActivity.Current.Activity;
|
||||
var activity = (MainActivity)Microsoft.Maui.ApplicationModel.Platform.CurrentActivity;
|
||||
var intent = BuildOpenFileIntent(new byte[0], string.Concat("opentest_", fileName));
|
||||
if (intent == null)
|
||||
{
|
||||
@ -87,7 +86,7 @@ namespace Bit.Droid.Services
|
||||
return null;
|
||||
}
|
||||
|
||||
var activity = (MainActivity)CrossCurrentActivity.Current.Activity;
|
||||
var activity = (MainActivity)Microsoft.Maui.ApplicationModel.Platform.CurrentActivity;
|
||||
var cachePath = activity.CacheDir;
|
||||
var filePath = Path.Combine(cachePath.Path, fileName);
|
||||
File.WriteAllBytes(filePath, fileData);
|
||||
@ -114,7 +113,7 @@ namespace Bit.Droid.Services
|
||||
{
|
||||
try
|
||||
{
|
||||
var activity = (MainActivity)CrossCurrentActivity.Current.Activity;
|
||||
var activity = (MainActivity)Microsoft.Maui.ApplicationModel.Platform.CurrentActivity;
|
||||
|
||||
if (contentUri != null)
|
||||
{
|
||||
@ -162,7 +161,7 @@ namespace Bit.Droid.Services
|
||||
{
|
||||
try
|
||||
{
|
||||
DeleteDir(CrossCurrentActivity.Current.Activity.CacheDir);
|
||||
DeleteDir(Microsoft.Maui.ApplicationModel.Platform.CurrentActivity?.CacheDir);
|
||||
await _stateService.SetLastFileCacheClearAsync(DateTime.UtcNow);
|
||||
}
|
||||
catch (Exception) { }
|
||||
@ -170,7 +169,7 @@ namespace Bit.Droid.Services
|
||||
|
||||
public Task SelectFileAsync()
|
||||
{
|
||||
var activity = (MainActivity)CrossCurrentActivity.Current.Activity;
|
||||
var activity = (MainActivity)Microsoft.Maui.ApplicationModel.Platform.CurrentActivity;
|
||||
var hasStorageWritePermission = !_cameraPermissionsDenied &&
|
||||
HasPermission(Manifest.Permission.WriteExternalStorage);
|
||||
var additionalIntents = new List<IParcelable>();
|
||||
@ -249,20 +248,30 @@ namespace Bit.Droid.Services
|
||||
|
||||
private bool HasPermission(string permission)
|
||||
{
|
||||
return ContextCompat.CheckSelfPermission(
|
||||
CrossCurrentActivity.Current.Activity, permission) == Permission.Granted;
|
||||
var activity = Microsoft.Maui.ApplicationModel.Platform.CurrentActivity;
|
||||
if (activity != null)
|
||||
{
|
||||
return ContextCompat.CheckSelfPermission(activity, permission) == Permission.Granted;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void AskPermission(string permission)
|
||||
{
|
||||
ActivityCompat.RequestPermissions(CrossCurrentActivity.Current.Activity, new string[] { permission },
|
||||
Core.Constants.SelectFilePermissionRequestCode);
|
||||
var activity = Microsoft.Maui.ApplicationModel.Platform.CurrentActivity;
|
||||
if (activity != null)
|
||||
{
|
||||
ActivityCompat.RequestPermissions(activity, new string[] { permission }, Core.Constants.SelectFilePermissionRequestCode);
|
||||
}
|
||||
}
|
||||
|
||||
private List<IParcelable> GetCameraIntents(Android.Net.Uri outputUri)
|
||||
{
|
||||
var intents = new List<IParcelable>();
|
||||
var pm = CrossCurrentActivity.Current.Activity.PackageManager;
|
||||
var pm = Microsoft.Maui.ApplicationModel.Platform.CurrentActivity?.PackageManager;
|
||||
var captureIntent = new Intent(MediaStore.ActionImageCapture);
|
||||
var listCam = pm.QueryIntentActivities(captureIntent, 0);
|
||||
foreach (var res in listCam)
|
||||
|
@ -72,7 +72,6 @@
|
||||
<Label
|
||||
Grid.Column="0"
|
||||
Grid.Row="0"
|
||||
HorizontalTextAlignment="Start"
|
||||
LineBreakMode="TailTruncation"
|
||||
StyleClass="list-title, list-title-platform"
|
||||
Text="{Binding Cipher.Name}"
|
||||
@ -81,7 +80,6 @@
|
||||
Grid.Column="0"
|
||||
Grid.Row="1"
|
||||
Grid.ColumnSpan="3"
|
||||
HorizontalTextAlignment="Start"
|
||||
LineBreakMode="TailTruncation"
|
||||
StyleClass="list-subtitle, list-subtitle-platform"
|
||||
Text="{Binding Cipher.SubTitle}"
|
||||
|
@ -47,7 +47,6 @@
|
||||
<PackageReference Include="Portable.BouncyCastle" Version="1.9.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">
|
||||
<PackageReference Include="Plugin.CurrentActivity" Version="2.1.0.4" />
|
||||
<PackageReference Include="Xamarin.AndroidX.AutoFill" Version="1.1.0.18" />
|
||||
<PackageReference Include="Xamarin.AndroidX.Activity.Ktx" Version="1.7.2.1" />
|
||||
</ItemGroup>
|
||||
|
Loading…
Reference in New Issue
Block a user