mirror of
https://github.com/bitwarden/mobile
synced 2026-01-03 00:53:27 +00:00
Deprecate XF.Context and give context to renderers
This commit is contained in:
@@ -89,7 +89,7 @@ namespace Bit.Android.Services
|
||||
{
|
||||
return App.Utilities.Crypto.AesCbcDecrypt(new App.Models.CipherString(cs), aesKey);
|
||||
}
|
||||
catch(Exception e)
|
||||
catch
|
||||
{
|
||||
Console.WriteLine("Failed to decrypt from secure storage.");
|
||||
_settings.Remove(formattedKey);
|
||||
@@ -120,7 +120,7 @@ namespace Bit.Android.Services
|
||||
var cipherString = App.Utilities.Crypto.AesCbcEncrypt(dataBytes, aesKey);
|
||||
_settings.AddOrUpdateValue(formattedKey, cipherString.EncryptedString);
|
||||
}
|
||||
catch(Exception e)
|
||||
catch
|
||||
{
|
||||
Console.WriteLine("Failed to encrypt to secure storage.");
|
||||
//Utilities.SendCrashEmail(e);
|
||||
@@ -224,7 +224,7 @@ namespace Bit.Android.Services
|
||||
return new App.Models.SymmetricCryptoKey(key);
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
catch
|
||||
{
|
||||
Console.WriteLine("Cannot get AesKey.");
|
||||
_keyStore.DeleteEntry(KeyAlias);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Android.App;
|
||||
using Android.Views.Autofill;
|
||||
using Bit.App.Abstractions;
|
||||
using Plugin.CurrentActivity;
|
||||
using System.Linq;
|
||||
using AndroidApp = Android.App.Application;
|
||||
|
||||
@@ -19,7 +20,7 @@ namespace Bit.Android.Services
|
||||
|
||||
private bool AutofillAccessibilityRunning()
|
||||
{
|
||||
var manager = ((ActivityManager)Xamarin.Forms.Forms.Context.GetSystemService("activity"));
|
||||
var manager = ((ActivityManager)CrossCurrentActivity.Current.Activity.GetSystemService("activity"));
|
||||
var services = manager.GetRunningServices(int.MaxValue);
|
||||
return services.Any(s => s.Process.ToLowerInvariant().Contains("bitwarden") &&
|
||||
s.Service.ClassName.ToLowerInvariant().Contains("autofill"));
|
||||
@@ -32,7 +33,7 @@ namespace Bit.Android.Services
|
||||
return false;
|
||||
}
|
||||
|
||||
var activity = (MainActivity)Xamarin.Forms.Forms.Context;
|
||||
var activity = (MainActivity)CrossCurrentActivity.Current.Activity;
|
||||
var afm = (AutofillManager)activity.GetSystemService(Java.Lang.Class.FromType(typeof(AutofillManager)));
|
||||
return afm.IsEnabled;
|
||||
}
|
||||
|
||||
@@ -43,9 +43,11 @@ namespace Bit.Android.Services
|
||||
_userDialogs = userDialogs;
|
||||
}
|
||||
|
||||
private Context CurrentContext => CrossCurrentActivity.Current.Activity;
|
||||
|
||||
public void CopyToClipboard(string text)
|
||||
{
|
||||
var clipboardManager = (ClipboardManager)Forms.Context.GetSystemService(Context.ClipboardService);
|
||||
var clipboardManager = (ClipboardManager)CurrentContext.GetSystemService(Context.ClipboardService);
|
||||
clipboardManager.Text = text;
|
||||
}
|
||||
|
||||
@@ -131,7 +133,7 @@ namespace Bit.Android.Services
|
||||
var hasStorageWritePermission = !_cameraPermissionsDenied && HasPermission(Manifest.Permission.WriteExternalStorage);
|
||||
|
||||
var additionalIntents = new List<IParcelable>();
|
||||
if(Forms.Context.PackageManager.HasSystemFeature(PackageManager.FeatureCamera))
|
||||
if(CurrentContext.PackageManager.HasSystemFeature(PackageManager.FeatureCamera))
|
||||
{
|
||||
var hasCameraPermission = !_cameraPermissionsDenied && HasPermission(Manifest.Permission.Camera);
|
||||
|
||||
@@ -181,7 +183,7 @@ namespace Bit.Android.Services
|
||||
|
||||
public void Autofill(VaultListPageModel.Cipher cipher)
|
||||
{
|
||||
var activity = (MainActivity)Forms.Context;
|
||||
var activity = (MainActivity)CurrentContext;
|
||||
if(activity.Intent.GetBooleanExtra("autofillFramework", false))
|
||||
{
|
||||
if(cipher == null)
|
||||
@@ -259,7 +261,7 @@ namespace Bit.Android.Services
|
||||
|
||||
public void Background()
|
||||
{
|
||||
var activity = (MainActivity)Forms.Context;
|
||||
var activity = (MainActivity)CurrentContext;
|
||||
if(activity.Intent.GetBooleanExtra("autofillFramework", false))
|
||||
{
|
||||
activity.SetResult(Result.Canceled);
|
||||
@@ -273,7 +275,7 @@ namespace Bit.Android.Services
|
||||
|
||||
public void RateApp()
|
||||
{
|
||||
var activity = (MainActivity)Forms.Context;
|
||||
var activity = (MainActivity)CurrentContext;
|
||||
try
|
||||
{
|
||||
var rateIntent = RateIntentForUrl("market://details", activity);
|
||||
@@ -288,7 +290,7 @@ namespace Bit.Android.Services
|
||||
|
||||
public void DismissKeyboard()
|
||||
{
|
||||
var activity = (MainActivity)Forms.Context;
|
||||
var activity = (MainActivity)CurrentContext;
|
||||
try
|
||||
{
|
||||
var imm = (InputMethodManager)activity.GetSystemService(Context.InputMethodService);
|
||||
@@ -299,14 +301,14 @@ namespace Bit.Android.Services
|
||||
|
||||
public void OpenAccessibilitySettings()
|
||||
{
|
||||
var activity = (MainActivity)Forms.Context;
|
||||
var activity = (MainActivity)CurrentContext;
|
||||
var intent = new Intent(Settings.ActionAccessibilitySettings);
|
||||
activity.StartActivity(intent);
|
||||
}
|
||||
|
||||
public void LaunchApp(string appName)
|
||||
{
|
||||
var activity = (MainActivity)Forms.Context;
|
||||
var activity = (MainActivity)CurrentContext;
|
||||
if(_lastAction.LastActionWasRecent())
|
||||
{
|
||||
return;
|
||||
@@ -410,7 +412,7 @@ namespace Bit.Android.Services
|
||||
|
||||
public void OpenAutofillSettings()
|
||||
{
|
||||
var activity = (MainActivity)Forms.Context;
|
||||
var activity = (MainActivity)CurrentContext;
|
||||
var intent = new Intent(Settings.ActionRequestSetAutofillService);
|
||||
intent.SetData(global::Android.Net.Uri.Parse("package:com.x8bit.bitwarden"));
|
||||
activity.StartActivity(intent);
|
||||
|
||||
@@ -3,6 +3,7 @@ using Android.Content.PM;
|
||||
using Android.OS;
|
||||
using Android.Views.Autofill;
|
||||
using Bit.App.Abstractions;
|
||||
using Plugin.CurrentActivity;
|
||||
|
||||
namespace Bit.Android.Services
|
||||
{
|
||||
@@ -45,7 +46,8 @@ namespace Bit.Android.Services
|
||||
}
|
||||
}
|
||||
public bool NfcEnabled => Utilities.NfcEnabled();
|
||||
public bool HasCamera => Xamarin.Forms.Forms.Context.PackageManager.HasSystemFeature(PackageManager.FeatureCamera);
|
||||
public bool HasCamera => CrossCurrentActivity.Current.Activity.PackageManager.HasSystemFeature(
|
||||
PackageManager.FeatureCamera);
|
||||
public bool AutofillServiceSupported => AutofillSupported();
|
||||
public bool HasFaceIdSupport => false;
|
||||
private bool AutofillSupported()
|
||||
@@ -54,9 +56,9 @@ namespace Bit.Android.Services
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var activity = (MainActivity)Xamarin.Forms.Forms.Context;
|
||||
var afm = (AutofillManager)activity.GetSystemService(Java.Lang.Class.FromType(typeof(AutofillManager)));
|
||||
|
||||
var afm = (AutofillManager)CrossCurrentActivity.Current.Activity.GetSystemService(
|
||||
Java.Lang.Class.FromType(typeof(AutofillManager)));
|
||||
return afm.IsAutofillSupported;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using Android.Content;
|
||||
using Bit.App.Abstractions;
|
||||
using Plugin.CurrentActivity;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace Bit.Android.Services
|
||||
@@ -9,12 +10,12 @@ namespace Bit.Android.Services
|
||||
{
|
||||
public MemoryInfo GetInfo()
|
||||
{
|
||||
return MemoryHelper.GetMemoryInfo(Forms.Context);
|
||||
return MemoryHelper.GetMemoryInfo(CrossCurrentActivity.Current.Activity);
|
||||
}
|
||||
|
||||
public void Check()
|
||||
{
|
||||
MemoryHelper.MemoryCheck(Forms.Context);
|
||||
MemoryHelper.MemoryCheck(CrossCurrentActivity.Current.Activity);
|
||||
}
|
||||
|
||||
public static class MemoryHelper
|
||||
|
||||
Reference in New Issue
Block a user