public SyncService( IUserService userService, IApiService apiService, ISettingsService settingsService, IFolderService folderService, ICipherService cipherService, ICryptoService cryptoService, ICollectionService collectionService, IStorageService storageService, IMessagingService messagingService, ICozyClientService cozyClientService, Func <bool, Task> logoutCallbackAsync) { _userService = userService; _apiService = apiService; _settingsService = settingsService; _folderService = folderService; _cipherService = cipherService; _cryptoService = cryptoService; _collectionService = collectionService; _storageService = storageService; _messagingService = messagingService; #region cozy _cozyClientService = cozyClientService; #endregion _logoutCallbackAsync = logoutCallbackAsync; }
public HintPageViewModel() { _deviceActionService = ServiceContainer.Resolve <IDeviceActionService>("deviceActionService"); _platformUtilsService = ServiceContainer.Resolve <IPlatformUtilsService>("platformUtilsService"); _apiService = ServiceContainer.Resolve <IApiService>("apiService"); _cozyClientService = ServiceContainer.Resolve <ICozyClientService>("cozyClientService"); PageTitle = AppResources.PasswordHint; SubmitCommand = new Command(async() => await SubmitAsync()); }
public HomePage() { _messagingService = ServiceContainer.Resolve <IMessagingService>("messagingService"); _platformUtilsService = ServiceContainer.Resolve <IPlatformUtilsService>("platformUtilsService"); _i18nService = ServiceContainer.Resolve <II18nService>("i18nService"); _cozyClientService = ServiceContainer.Resolve <ICozyClientService>("cozyClientService"); _broadcasterService = ServiceContainer.Resolve <IBroadcasterService>("broadcasterService"); _messagingService.Send("showStatusBar", false); InitializeComponent(); _logo.Source = !ThemeManager.UsingLightTheme ? "logo_white.png" : "logo.png"; }
public LoginPageViewModel() { _deviceActionService = ServiceContainer.Resolve <IDeviceActionService>("deviceActionService"); _authService = ServiceContainer.Resolve <IAuthService>("authService"); _syncService = ServiceContainer.Resolve <ISyncService>("syncService"); _storageService = ServiceContainer.Resolve <IStorageService>("storageService"); _platformUtilsService = ServiceContainer.Resolve <IPlatformUtilsService>("platformUtilsService"); _stateService = ServiceContainer.Resolve <IStateService>("stateService"); _cozyClientService = ServiceContainer.Resolve <ICozyClientService>("cozyClientService"); PageTitle = AppResources.CozyPass; TogglePasswordCommand = new Command(TogglePassword); LogInCommand = new Command(async() => await LogInAsync()); }
public SettingsPageViewModel() { _platformUtilsService = ServiceContainer.Resolve <IPlatformUtilsService>("platformUtilsService"); _cryptoService = ServiceContainer.Resolve <ICryptoService>("cryptoService"); _userService = ServiceContainer.Resolve <IUserService>("userService"); _deviceActionService = ServiceContainer.Resolve <IDeviceActionService>("deviceActionService"); _environmentService = ServiceContainer.Resolve <IEnvironmentService>("environmentService"); _messagingService = ServiceContainer.Resolve <IMessagingService>("messagingService"); _lockService = ServiceContainer.Resolve <ILockService>("lockService"); _storageService = ServiceContainer.Resolve <IStorageService>("storageService"); _syncService = ServiceContainer.Resolve <ISyncService>("syncService"); _cozyClientService = ServiceContainer.Resolve <ICozyClientService>("cozyClientService"); _i18nService = ServiceContainer.Resolve <II18nService>("i18nService"); GroupedItems = new ExtendedObservableCollection <SettingsPageListGroup>(); PageTitle = AppResources.Settings; }
public override bool FinishedLaunching(UIApplication app, NSDictionary options) { Forms.Init(); InitApp(); _deviceActionService = ServiceContainer.Resolve <IDeviceActionService>("deviceActionService"); _messagingService = ServiceContainer.Resolve <IMessagingService>("messagingService"); _broadcasterService = ServiceContainer.Resolve <IBroadcasterService>("broadcasterService"); _storageService = ServiceContainer.Resolve <IStorageService>("storageService"); _lockService = ServiceContainer.Resolve <ILockService>("lockService"); _eventService = ServiceContainer.Resolve <IEventService>("eventService"); _platformUtilsService = ServiceContainer.Resolve <IPlatformUtilsService>("platformUtilsService"); _cozyClientService = ServiceContainer.Resolve <ICozyClientService>("cozyClientService"); LoadApplication(new App.App(null)); iOSCoreHelpers.AppearanceAdjustments(_deviceActionService); ZXing.Net.Mobile.Forms.iOS.Platform.Init(); _broadcasterService.Subscribe(nameof(AppDelegate), async(message) => { if (message.Command == "scheduleLockTimer") { LockTimer((int)message.Data); } else if (message.Command == "cancelLockTimer") { CancelLockTimer(); } else if (message.Command == "startEventTimer") { StartEventTimer(); } else if (message.Command == "stopEventTimer") { var task = StopEventTimerAsync(); } else if (message.Command == "updatedTheme") { // ThemeManager.SetThemeStyle(message.Data as string); } else if (message.Command == "copiedToClipboard") { Device.BeginInvokeOnMainThread(() => { var task = ClearClipboardTimerAsync(message.Data as Tuple <string, int?, bool>); }); } else if (message.Command == "listenYubiKeyOTP") { ListenYubiKey((bool)message.Data); } else if (message.Command == "unlocked") { var needsAutofillReplacement = await _storageService.GetAsync <bool?>( Core.Constants.AutofillNeedsIdentityReplacementKey); if (needsAutofillReplacement.GetValueOrDefault()) { await ASHelpers.ReplaceAllIdentities(); } } else if (message.Command == "showAppExtension") { Device.BeginInvokeOnMainThread(() => ShowAppExtension((ExtensionPageViewModel)message.Data)); } else if (message.Command == "showStatusBar") { Device.BeginInvokeOnMainThread(() => UIApplication.SharedApplication.SetStatusBarHidden(!(bool)message.Data, false)); } else if (message.Command == "syncCompleted") { if (message.Data is Dictionary <string, object> data && data.ContainsKey("successfully")) { var success = data["successfully"] as bool?; if (success.GetValueOrDefault() && _deviceActionService.SystemMajorVersion() >= 12) { await ASHelpers.ReplaceAllIdentities(); } } } else if (message.Command == "addedCipher" || message.Command == "editedCipher") { if (_deviceActionService.SystemMajorVersion() >= 12) { if (await ASHelpers.IdentitiesCanIncremental()) { var cipherId = message.Data as string; if (message.Command == "addedCipher" && !string.IsNullOrWhiteSpace(cipherId)) { var identity = await ASHelpers.GetCipherIdentityAsync(cipherId); if (identity == null) { return; } await ASCredentialIdentityStore.SharedStore?.SaveCredentialIdentitiesAsync( new ASPasswordCredentialIdentity[] { identity }); return; } } await ASHelpers.ReplaceAllIdentities(); } } else if (message.Command == "deletedCipher") { if (_deviceActionService.SystemMajorVersion() >= 12) { if (await ASHelpers.IdentitiesCanIncremental()) { var identity = ASHelpers.ToCredentialIdentity( message.Data as Bit.Core.Models.View.CipherView); if (identity == null) { return; } await ASCredentialIdentityStore.SharedStore?.RemoveCredentialIdentitiesAsync( new ASPasswordCredentialIdentity[] { identity }); return; } await ASHelpers.ReplaceAllIdentities(); } } else if (message.Command == "loggedOut") { if (_deviceActionService.SystemMajorVersion() >= 12) { await ASCredentialIdentityStore.SharedStore?.RemoveAllCredentialIdentitiesAsync(); } } }); return(base.FinishedLaunching(app, options)); }
protected override void OnCreate(Bundle savedInstanceState) { var eventUploadIntent = new Intent(this, typeof(EventUploadReceiver)); _eventUploadPendingIntent = PendingIntent.GetBroadcast(this, 0, eventUploadIntent, PendingIntentFlags.UpdateCurrent); var alarmIntent = new Intent(this, typeof(LockAlarmReceiver)); _lockAlarmPendingIntent = PendingIntent.GetBroadcast(this, 0, alarmIntent, PendingIntentFlags.UpdateCurrent); var clearClipboardIntent = new Intent(this, typeof(ClearClipboardAlarmReceiver)); _clearClipboardPendingIntent = PendingIntent.GetBroadcast(this, 0, clearClipboardIntent, PendingIntentFlags.UpdateCurrent); var policy = new StrictMode.ThreadPolicy.Builder().PermitAll().Build(); StrictMode.SetThreadPolicy(policy); _deviceActionService = ServiceContainer.Resolve <IDeviceActionService>("deviceActionService"); _messagingService = ServiceContainer.Resolve <IMessagingService>("messagingService"); _broadcasterService = ServiceContainer.Resolve <IBroadcasterService>("broadcasterService"); _userService = ServiceContainer.Resolve <IUserService>("userService"); _appIdService = ServiceContainer.Resolve <IAppIdService>("appIdService"); _storageService = ServiceContainer.Resolve <IStorageService>("storageService"); _eventService = ServiceContainer.Resolve <IEventService>("eventService"); _cozyClientService = ServiceContainer.Resolve <ICozyClientService>("cozyClientService"); TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; UpdateTheme(ThemeManager.GetTheme(true)); base.OnCreate(savedInstanceState); if (!CoreHelpers.InDebugMode()) { Window.AddFlags(Android.Views.WindowManagerFlags.Secure); } Xamarin.Essentials.Platform.Init(this, savedInstanceState); Xamarin.Forms.Forms.Init(this, savedInstanceState); _appOptions = GetOptions(); LoadApplication(new App.App(_appOptions)); _broadcasterService.Subscribe(_activityKey, (message) => { if (message.Command == "scheduleLockTimer") { var alarmManager = GetSystemService(AlarmService) as AlarmManager; var lockOptionMinutes = (int)message.Data; var lockOptionMs = lockOptionMinutes * 60000; var triggerMs = Java.Lang.JavaSystem.CurrentTimeMillis() + lockOptionMs + 10; alarmManager.Set(AlarmType.RtcWakeup, triggerMs, _lockAlarmPendingIntent); } else if (message.Command == "cancelLockTimer") { var alarmManager = GetSystemService(AlarmService) as AlarmManager; alarmManager.Cancel(_lockAlarmPendingIntent); } else if (message.Command == "startEventTimer") { StartEventAlarm(); } else if (message.Command == "stopEventTimer") { var task = StopEventAlarmAsync(); } else if (message.Command == "finishMainActivity") { Xamarin.Forms.Device.BeginInvokeOnMainThread(() => Finish()); } else if (message.Command == "listenYubiKeyOTP") { ListenYubiKey((bool)message.Data); } else if (message.Command == "updatedTheme") { RestartApp(); } else if (message.Command == "exit") { ExitApp(); } else if (message.Command == "copiedToClipboard") { var task = ClearClipboardAlarmAsync(message.Data as Tuple <string, int?, bool>); } }); }
public App(AppOptions appOptions) { _appOptions = appOptions ?? new AppOptions(); _userService = ServiceContainer.Resolve <IUserService>("userService"); _broadcasterService = ServiceContainer.Resolve <IBroadcasterService>("broadcasterService"); _messagingService = ServiceContainer.Resolve <IMessagingService>("messagingService"); _stateService = ServiceContainer.Resolve <IStateService>("stateService"); _lockService = ServiceContainer.Resolve <ILockService>("lockService"); _syncService = ServiceContainer.Resolve <ISyncService>("syncService"); _tokenService = ServiceContainer.Resolve <ITokenService>("tokenService"); _cryptoService = ServiceContainer.Resolve <ICryptoService>("cryptoService"); _cipherService = ServiceContainer.Resolve <ICipherService>("cipherService"); _folderService = ServiceContainer.Resolve <IFolderService>("folderService"); _settingsService = ServiceContainer.Resolve <ISettingsService>("settingsService"); _collectionService = ServiceContainer.Resolve <ICollectionService>("collectionService"); _searchService = ServiceContainer.Resolve <ISearchService>("searchService"); _authService = ServiceContainer.Resolve <IAuthService>("authService"); _platformUtilsService = ServiceContainer.Resolve <IPlatformUtilsService>("platformUtilsService"); _storageService = ServiceContainer.Resolve <IStorageService>("storageService"); _secureStorageService = ServiceContainer.Resolve <IStorageService>("secureStorageService"); _passwordGenerationService = ServiceContainer.Resolve <IPasswordGenerationService>( "passwordGenerationService"); _i18nService = ServiceContainer.Resolve <II18nService>("i18nService") as MobileI18nService; _deviceActionService = ServiceContainer.Resolve <IDeviceActionService>("deviceActionService"); _cozyClientService = ServiceContainer.Resolve <ICozyClientService>("cozyClientService"); Bootstrap(); _broadcasterService.Subscribe(nameof(App), async(message) => { if (message.Command == "showDialog") { var details = message.Data as DialogDetails; var confirmed = true; var confirmText = string.IsNullOrWhiteSpace(details.ConfirmText) ? AppResources.Ok : details.ConfirmText; Device.BeginInvokeOnMainThread(async() => { if (!string.IsNullOrWhiteSpace(details.CancelText)) { confirmed = await Current.MainPage.DisplayAlert(details.Title, details.Text, confirmText, details.CancelText); } else { await Current.MainPage.DisplayAlert(details.Title, details.Text, confirmText); } _messagingService.Send("showDialogResolve", new Tuple <int, bool>(details.DialogId, confirmed)); }); } else if (message.Command == "locked") { await LockedAsync(!(message.Data as bool?).GetValueOrDefault()); } else if (message.Command == "lockVault") { await _lockService.LockAsync(true); } else if (message.Command == "logout") { Device.BeginInvokeOnMainThread(async() => await LogOutAsync((message.Data as bool?).GetValueOrDefault())); } else if (message.Command == "loggedOut") { // Clean up old migrated key if they ever log out. await _secureStorageService.RemoveAsync("oldKey"); } else if (message.Command == "resumed") { if (Device.RuntimePlatform == Device.iOS) { ResumedAsync(); } } else if (message.Command == "slept") { if (Device.RuntimePlatform == Device.iOS) { await SleptAsync(); } } else if (message.Command == "migrated") { await Task.Delay(1000); await SetMainPageAsync(); } else if (message.Command == "popAllAndGoToTabGenerator" || message.Command == "popAllAndGoToTabMyVault") { Device.BeginInvokeOnMainThread(async() => { if (Current.MainPage is TabsPage tabsPage) { while (tabsPage.Navigation.ModalStack.Count > 0) { await tabsPage.Navigation.PopModalAsync(false); } if (message.Command == "popAllAndGoToTabMyVault") { _appOptions.MyVaultTile = false; tabsPage.ResetToVaultPage(); } else { _appOptions.GeneratorTile = false; tabsPage.ResetToGeneratorPage(); } } }); } }); }