From 9f23f4ead7a090f6dc96daac4056be1b48d99e74 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Fri, 22 Dec 2017 15:00:11 -0500 Subject: [PATCH] custom toast implementations --- src/Android/Resources/Resource.Designer.cs | 33 ++++--------------- src/Android/Services/DeviceActionService.cs | 6 ++++ .../Services/IDeviceActionService.cs | 1 + src/App/Pages/EnvironmentPage.cs | 4 ++- src/App/Pages/HomePage.cs | 6 ++-- src/App/Pages/LoginTwoFactorPage.cs | 2 +- .../Pages/Settings/SettingsAddFolderPage.cs | 4 ++- .../Pages/Settings/SettingsEditFolderPage.cs | 6 ++-- src/App/Pages/Settings/SettingsSyncPage.cs | 6 ++-- .../Pages/Tools/ToolsPasswordGeneratorPage.cs | 10 +++--- src/App/Pages/Vault/VaultAddCipherPage.cs | 6 ++-- src/App/Pages/Vault/VaultAttachmentsPage.cs | 10 +++--- .../Vault/VaultAutofillListCiphersPage.cs | 12 +++---- src/App/Pages/Vault/VaultCustomFieldsPage.cs | 4 ++- src/App/Pages/Vault/VaultEditCipherPage.cs | 10 +++--- src/App/Pages/Vault/VaultViewCipherPage.cs | 2 +- src/App/Services/AuthService.cs | 2 +- src/App/Utilities/Helpers.cs | 5 +-- src/UWP/Services/DeviceActionService.cs | 26 +++++++++++++-- src/UWP/UWP.csproj | 2 +- src/iOS/Services/DeviceActionService.cs | 10 ++++++ src/iOS/iOS.csproj | 3 ++ 22 files changed, 101 insertions(+), 69 deletions(-) diff --git a/src/Android/Resources/Resource.Designer.cs b/src/Android/Resources/Resource.Designer.cs index cfc2115d4..8677cf1ee 100644 --- a/src/Android/Resources/Resource.Designer.cs +++ b/src/Android/Resources/Resource.Designer.cs @@ -4375,17 +4375,17 @@ namespace Bit.Android // aapt resource value: 0x7f090051 public const int ApplicationName = 2131296337; - // aapt resource value: 0x7f0900b2 - public const int AutoFillServiceDescription = 2131296434; + // aapt resource value: 0x7f0900ab + public const int AutoFillServiceDescription = 2131296427; - // aapt resource value: 0x7f0900b1 - public const int AutoFillServiceSummary = 2131296433; + // aapt resource value: 0x7f0900aa + public const int AutoFillServiceSummary = 2131296426; // aapt resource value: 0x7f090050 public const int Hello = 2131296336; - // aapt resource value: 0x7f0900b3 - public const int MyVault = 2131296435; + // aapt resource value: 0x7f0900ac + public const int MyVault = 2131296428; // aapt resource value: 0x7f090027 public const int abc_action_bar_home_description = 2131296295; @@ -4540,27 +4540,6 @@ namespace Bit.Android // aapt resource value: 0x7f09000f public const int common_signin_button_text_long = 2131296271; - // aapt resource value: 0x7f0900ac - public const int default_web_client_id = 2131296428; - - // aapt resource value: 0x7f0900ad - public const int firebase_database_url = 2131296429; - - // aapt resource value: 0x7f0900aa - public const int gcm_defaultSenderId = 2131296426; - - // aapt resource value: 0x7f0900ae - public const int google_api_key = 2131296430; - - // aapt resource value: 0x7f0900ab - public const int google_app_id = 2131296427; - - // aapt resource value: 0x7f0900af - public const int google_crash_reporting_api_key = 2131296431; - - // aapt resource value: 0x7f0900b0 - public const int google_storage_bucket = 2131296432; - // aapt resource value: 0x7f090052 public const int hockeyapp_crash_dialog_app_name_fallback = 2131296338; diff --git a/src/Android/Services/DeviceActionService.cs b/src/Android/Services/DeviceActionService.cs index ed7a8fec5..18f0fa8ec 100644 --- a/src/Android/Services/DeviceActionService.cs +++ b/src/Android/Services/DeviceActionService.cs @@ -45,6 +45,12 @@ namespace Bit.Android.Services private Context CurrentContext => CrossCurrentActivity.Current.Activity; + public void Toast(string text, bool longDuration = false) + { + global::Android.Widget.Toast.MakeText(CurrentContext, text, + longDuration ? global::Android.Widget.ToastLength.Long : global::Android.Widget.ToastLength.Short).Show(); + } + public void CopyToClipboard(string text) { var clipboardManager = (ClipboardManager)CurrentContext.GetSystemService(Context.ClipboardService); diff --git a/src/App/Abstractions/Services/IDeviceActionService.cs b/src/App/Abstractions/Services/IDeviceActionService.cs index 991f01031..b31ae08f7 100644 --- a/src/App/Abstractions/Services/IDeviceActionService.cs +++ b/src/App/Abstractions/Services/IDeviceActionService.cs @@ -5,6 +5,7 @@ namespace Bit.App.Abstractions { public interface IDeviceActionService { + void Toast(string text, bool longDuration = false); void CopyToClipboard(string text); bool OpenFile(byte[] fileData, string id, string fileName); bool CanOpenFile(string fileName); diff --git a/src/App/Pages/EnvironmentPage.cs b/src/App/Pages/EnvironmentPage.cs index 03af0ad5d..f11d1d476 100644 --- a/src/App/Pages/EnvironmentPage.cs +++ b/src/App/Pages/EnvironmentPage.cs @@ -14,6 +14,7 @@ namespace Bit.App.Pages { private IAppSettingsService _appSettings; private IUserDialogs _userDialogs; + private IDeviceActionService _deviceActionService; private IGoogleAnalyticsService _googleAnalyticsService; public EnvironmentPage() @@ -21,6 +22,7 @@ namespace Bit.App.Pages { _appSettings = Resolver.Resolve(); _userDialogs = Resolver.Resolve(); + _deviceActionService = Resolver.Resolve(); _googleAnalyticsService = Resolver.Resolve(); Init(); @@ -238,7 +240,7 @@ namespace Bit.App.Pages _appSettings.IdentityUrl = IdentityUrlCell.Entry.Text; _appSettings.ApiUrl = ApiUrlCell.Entry.Text; _appSettings.WebVaultUrl = WebVaultUrlCell.Entry.Text; - _userDialogs.Toast(AppResources.EnvironmentSaved); + _deviceActionService.Toast(AppResources.EnvironmentSaved); _googleAnalyticsService.TrackAppEvent("SetEnvironmentUrls"); await Navigation.PopForDeviceAsync(); } diff --git a/src/App/Pages/HomePage.cs b/src/App/Pages/HomePage.cs index 03ef82383..b16d788a7 100644 --- a/src/App/Pages/HomePage.cs +++ b/src/App/Pages/HomePage.cs @@ -14,15 +14,15 @@ namespace Bit.App.Pages public class HomePage : ExtendedContentPage { private readonly IAuthService _authService; - private readonly IUserDialogs _userDialogs; private readonly ISettings _settings; + private readonly IDeviceActionService _deviceActionService; private DateTime? _lastAction; public HomePage() : base(updateActivity: false) { _authService = Resolver.Resolve(); - _userDialogs = Resolver.Resolve(); + _deviceActionService = Resolver.Resolve(); _settings = Resolver.Resolve(); Init(); @@ -130,7 +130,7 @@ namespace Bit.App.Pages { await Navigation.PopForDeviceAsync(); await Navigation.PushForDeviceAsync(new LoginPage(email)); - _userDialogs.Toast(AppResources.AccountCreated); + _deviceActionService.Toast(AppResources.AccountCreated); } public async Task SettingsAsync() diff --git a/src/App/Pages/LoginTwoFactorPage.cs b/src/App/Pages/LoginTwoFactorPage.cs index 4952c5033..7f0b38b1f 100644 --- a/src/App/Pages/LoginTwoFactorPage.cs +++ b/src/App/Pages/LoginTwoFactorPage.cs @@ -373,7 +373,7 @@ namespace Bit.App.Pages if(response.Succeeded && doToast) { - _userDialogs.Toast(AppResources.VerificationEmailSent); + _deviceActionService.Toast(AppResources.VerificationEmailSent); } else if(!response.Succeeded) { diff --git a/src/App/Pages/Settings/SettingsAddFolderPage.cs b/src/App/Pages/Settings/SettingsAddFolderPage.cs index fa0c65a5a..1e06a6de1 100644 --- a/src/App/Pages/Settings/SettingsAddFolderPage.cs +++ b/src/App/Pages/Settings/SettingsAddFolderPage.cs @@ -16,6 +16,7 @@ namespace Bit.App.Pages { private readonly IFolderService _folderService; private readonly IUserDialogs _userDialogs; + private readonly IDeviceActionService _deviceActionService; private readonly IConnectivity _connectivity; private readonly IGoogleAnalyticsService _googleAnalyticsService; private DateTime? _lastAction; @@ -24,6 +25,7 @@ namespace Bit.App.Pages { _folderService = Resolver.Resolve(); _userDialogs = Resolver.Resolve(); + _deviceActionService = Resolver.Resolve(); _connectivity = Resolver.Resolve(); _googleAnalyticsService = Resolver.Resolve(); @@ -89,7 +91,7 @@ namespace Bit.App.Pages if(saveResult.Succeeded) { - _userDialogs.Toast(AppResources.FolderCreated); + _deviceActionService.Toast(AppResources.FolderCreated); _googleAnalyticsService.TrackAppEvent("CreatedFolder"); await Navigation.PopForDeviceAsync(); } diff --git a/src/App/Pages/Settings/SettingsEditFolderPage.cs b/src/App/Pages/Settings/SettingsEditFolderPage.cs index 2055010cc..381d2df90 100644 --- a/src/App/Pages/Settings/SettingsEditFolderPage.cs +++ b/src/App/Pages/Settings/SettingsEditFolderPage.cs @@ -16,6 +16,7 @@ namespace Bit.App.Pages private readonly string _folderId; private readonly IFolderService _folderService; private readonly IUserDialogs _userDialogs; + private readonly IDeviceActionService _deviceActionService; private readonly IConnectivity _connectivity; private readonly IGoogleAnalyticsService _googleAnalyticsService; private DateTime? _lastAction; @@ -25,6 +26,7 @@ namespace Bit.App.Pages _folderId = folderId; _folderService = Resolver.Resolve(); _userDialogs = Resolver.Resolve(); + _deviceActionService = Resolver.Resolve(); _connectivity = Resolver.Resolve(); _googleAnalyticsService = Resolver.Resolve(); @@ -103,7 +105,7 @@ namespace Bit.App.Pages if(saveResult.Succeeded) { - _userDialogs.Toast(AppResources.FolderUpdated); + _deviceActionService.Toast(AppResources.FolderUpdated); _googleAnalyticsService.TrackAppEvent("EditedFolder"); await Navigation.PopForDeviceAsync(); } @@ -166,7 +168,7 @@ namespace Bit.App.Pages if(deleteTask.Succeeded) { - _userDialogs.Toast(AppResources.FolderDeleted); + _deviceActionService.Toast(AppResources.FolderDeleted); await Navigation.PopForDeviceAsync(); } else if(deleteTask.Errors.Count() > 0) diff --git a/src/App/Pages/Settings/SettingsSyncPage.cs b/src/App/Pages/Settings/SettingsSyncPage.cs index e79b3e728..f8ffb71d5 100644 --- a/src/App/Pages/Settings/SettingsSyncPage.cs +++ b/src/App/Pages/Settings/SettingsSyncPage.cs @@ -15,6 +15,7 @@ namespace Bit.App.Pages { private readonly ISyncService _syncService; private readonly IUserDialogs _userDialogs; + private readonly IDeviceActionService _deviceActionService; private readonly IConnectivity _connectivity; private readonly ISettings _settings; private readonly IGoogleAnalyticsService _googleAnalyticsService; @@ -23,6 +24,7 @@ namespace Bit.App.Pages { _syncService = Resolver.Resolve(); _userDialogs = Resolver.Resolve(); + _deviceActionService = Resolver.Resolve(); _connectivity = Resolver.Resolve(); _settings = Resolver.Resolve(); _googleAnalyticsService = Resolver.Resolve(); @@ -107,12 +109,12 @@ namespace Bit.App.Pages _userDialogs.HideLoading(); if(succeeded) { - _userDialogs.Toast(AppResources.SyncingComplete); + _deviceActionService.Toast(AppResources.SyncingComplete); _googleAnalyticsService.TrackAppEvent("Synced"); } else { - _userDialogs.Toast(AppResources.SyncingFailed); + _deviceActionService.Toast(AppResources.SyncingFailed); } SetLastSync(); diff --git a/src/App/Pages/Tools/ToolsPasswordGeneratorPage.cs b/src/App/Pages/Tools/ToolsPasswordGeneratorPage.cs index f07d1bb6a..12a76a8ed 100644 --- a/src/App/Pages/Tools/ToolsPasswordGeneratorPage.cs +++ b/src/App/Pages/Tools/ToolsPasswordGeneratorPage.cs @@ -13,20 +13,18 @@ namespace Bit.App.Pages { public class ToolsPasswordGeneratorPage : ExtendedContentPage { - private readonly IUserDialogs _userDialogs; private readonly IPasswordGenerationService _passwordGenerationService; private readonly ISettings _settings; - private readonly IDeviceActionService _clipboardService; + private readonly IDeviceActionService _deviceActionService; private readonly IGoogleAnalyticsService _googleAnalyticsService; private readonly Action _passwordValueAction; private readonly bool _fromAutofill; public ToolsPasswordGeneratorPage(Action passwordValueAction = null, bool fromAutofill = false) { - _userDialogs = Resolver.Resolve(); _passwordGenerationService = Resolver.Resolve(); _settings = Resolver.Resolve(); - _clipboardService = Resolver.Resolve(); + _deviceActionService = Resolver.Resolve(); _googleAnalyticsService = Resolver.Resolve(); _passwordValueAction = passwordValueAction; _fromAutofill = fromAutofill; @@ -278,8 +276,8 @@ namespace Bit.App.Pages { _googleAnalyticsService.TrackAppEvent("CopiedGeneratedPassword"); } - _clipboardService.CopyToClipboard(Password.Text); - _userDialogs.Toast(string.Format(AppResources.ValueHasBeenCopied, AppResources.Password)); + _deviceActionService.CopyToClipboard(Password.Text); + _deviceActionService.Toast(string.Format(AppResources.ValueHasBeenCopied, AppResources.Password)); } private void AvoidAmbiguousCell_OnChanged(object sender, ToggledEventArgs e) diff --git a/src/App/Pages/Vault/VaultAddCipherPage.cs b/src/App/Pages/Vault/VaultAddCipherPage.cs index 6c4bc7e01..b56db7dcf 100644 --- a/src/App/Pages/Vault/VaultAddCipherPage.cs +++ b/src/App/Pages/Vault/VaultAddCipherPage.cs @@ -335,7 +335,7 @@ namespace Bit.App.Pages if(!string.IsNullOrWhiteSpace(key)) { LoginTotpCell.Entry.Text = key; - _userDialogs.Toast(AppResources.AuthenticatorKeyAdded); + _deviceActionService.Toast(AppResources.AuthenticatorKeyAdded); } else { @@ -352,7 +352,7 @@ namespace Bit.App.Pages var page = new ToolsPasswordGeneratorPage((password) => { LoginPasswordCell.Entry.Text = password; - _userDialogs.Toast(AppResources.PasswordGenerated); + _deviceActionService.Toast(AppResources.PasswordGenerated); }, _fromAutofill); await Navigation.PushForDeviceAsync(page); } @@ -750,7 +750,7 @@ namespace Bit.App.Pages if(saveTask.Succeeded) { - _userDialogs.Toast(AppResources.NewItemCreated); + _deviceActionService.Toast(AppResources.NewItemCreated); if(_fromAutofill) { _googleAnalyticsService.TrackExtensionEvent("CreatedCipher"); diff --git a/src/App/Pages/Vault/VaultAttachmentsPage.cs b/src/App/Pages/Vault/VaultAttachmentsPage.cs index d7aeeda70..334492c99 100644 --- a/src/App/Pages/Vault/VaultAttachmentsPage.cs +++ b/src/App/Pages/Vault/VaultAttachmentsPage.cs @@ -19,7 +19,7 @@ namespace Bit.App.Pages private readonly ICipherService _cipherService; private readonly IUserDialogs _userDialogs; private readonly IConnectivity _connectivity; - private readonly IDeviceActionService _deviceActiveService; + private readonly IDeviceActionService _deviceActionService; private readonly IGoogleAnalyticsService _googleAnalyticsService; private readonly ITokenService _tokenService; private readonly ICryptoService _cryptoService; @@ -36,7 +36,7 @@ namespace Bit.App.Pages _cipherService = Resolver.Resolve(); _connectivity = Resolver.Resolve(); _userDialogs = Resolver.Resolve(); - _deviceActiveService = Resolver.Resolve(); + _deviceActionService = Resolver.Resolve(); _googleAnalyticsService = Resolver.Resolve(); _tokenService = Resolver.Resolve(); _cryptoService = Resolver.Resolve(); @@ -61,7 +61,7 @@ namespace Bit.App.Pages var selectButton = new ExtendedButton { Text = AppResources.ChooseFile, - Command = new Command(async () => await _deviceActiveService.SelectFileAsync()), + Command = new Command(async () => await _deviceActionService.SelectFileAsync()), Style = (Style)Application.Current.Resources["btn-primaryAccent"], FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Button)) }; @@ -169,7 +169,7 @@ namespace Bit.App.Pages { _fileBytes = null; FileLabel.Text = AppResources.NoFileChosen; - _userDialogs.Toast(AppResources.AttachementAdded); + _deviceActionService.Toast(AppResources.AttachementAdded); _googleAnalyticsService.TrackAppEvent("AddedAttachment"); await LoadAttachmentsAsync(); } @@ -272,7 +272,7 @@ namespace Bit.App.Pages if(saveTask.Succeeded) { - _userDialogs.Toast(AppResources.AttachmentDeleted); + _deviceActionService.Toast(AppResources.AttachmentDeleted); _googleAnalyticsService.TrackAppEvent("DeletedAttachment"); await LoadAttachmentsAsync(); } diff --git a/src/App/Pages/Vault/VaultAutofillListCiphersPage.cs b/src/App/Pages/Vault/VaultAutofillListCiphersPage.cs index 85e5e17b6..546c5f3a2 100644 --- a/src/App/Pages/Vault/VaultAutofillListCiphersPage.cs +++ b/src/App/Pages/Vault/VaultAutofillListCiphersPage.cs @@ -21,7 +21,6 @@ namespace Bit.App.Pages { private readonly ICipherService _cipherService; private readonly IDeviceInfoService _deviceInfoService; - private readonly IDeviceActionService _deviceActionService; private readonly ISettingsService _settingsService; private readonly IAppSettingsService _appSettingsService; private CancellationTokenSource _filterResultsCancellationTokenSource; @@ -45,7 +44,7 @@ namespace Bit.App.Pages _cipherService = Resolver.Resolve(); _deviceInfoService = Resolver.Resolve(); - _deviceActionService = Resolver.Resolve(); + DeviceActionService = Resolver.Resolve(); _settingsService = Resolver.Resolve(); UserDialogs = Resolver.Resolve(); _appSettingsService = Resolver.Resolve(); @@ -63,6 +62,7 @@ namespace Bit.App.Pages private AddCipherToolBarItem AddCipherItem { get; set; } private IGoogleAnalyticsService GoogleAnalyticsService { get; set; } private IUserDialogs UserDialogs { get; set; } + private IDeviceActionService DeviceActionService { get; set; } private string Uri { get; set; } private void Init() @@ -143,7 +143,7 @@ namespace Bit.App.Pages protected override bool OnBackButtonPressed() { GoogleAnalyticsService.TrackExtensionEvent("BackClosed", Uri.StartsWith("http") ? "Website" : "App"); - _deviceActionService.CloseAutofill(); + DeviceActionService.CloseAutofill(); return true; } @@ -245,7 +245,7 @@ namespace Bit.App.Pages if(doAutofill) { GoogleAnalyticsService.TrackExtensionEvent("AutoFilled", Uri.StartsWith("http") ? "Website" : "App"); - _deviceActionService.Autofill(cipher); + DeviceActionService.Autofill(cipher); } } @@ -294,8 +294,8 @@ namespace Bit.App.Pages _page.GoogleAnalyticsService.TrackExtensionEvent("CloseToSearch", _page.Uri.StartsWith("http") ? "Website" : "App"); Application.Current.MainPage = new ExtendedNavigationPage(new VaultListCiphersPage(uri: _page.Uri)); - _page.UserDialogs.Toast(string.Format(AppResources.BitwardenAutofillServiceSearch, _page._name), - TimeSpan.FromSeconds(10)); + _page.DeviceActionService.Toast(string.Format(AppResources.BitwardenAutofillServiceSearch, _page._name), + true); } } } diff --git a/src/App/Pages/Vault/VaultCustomFieldsPage.cs b/src/App/Pages/Vault/VaultCustomFieldsPage.cs index 42a221691..0782f2954 100644 --- a/src/App/Pages/Vault/VaultCustomFieldsPage.cs +++ b/src/App/Pages/Vault/VaultCustomFieldsPage.cs @@ -18,6 +18,7 @@ namespace Bit.App.Pages { private readonly ICipherService _cipherService; private readonly IUserDialogs _userDialogs; + private readonly IDeviceActionService _deviceActionService; private readonly IConnectivity _connectivity; private readonly IGoogleAnalyticsService _googleAnalyticsService; private readonly string _cipherId; @@ -31,6 +32,7 @@ namespace Bit.App.Pages _cipherService = Resolver.Resolve(); _connectivity = Resolver.Resolve(); _userDialogs = Resolver.Resolve(); + _deviceActionService = Resolver.Resolve(); _googleAnalyticsService = Resolver.Resolve(); Init(); @@ -120,7 +122,7 @@ namespace Bit.App.Pages if(saveTask.Succeeded) { - _userDialogs.Toast(AppResources.CustomFieldsUpdated); + _deviceActionService.Toast(AppResources.CustomFieldsUpdated); _googleAnalyticsService.TrackAppEvent("UpdatedCustomFields"); await Navigation.PopForDeviceAsync(); } diff --git a/src/App/Pages/Vault/VaultEditCipherPage.cs b/src/App/Pages/Vault/VaultEditCipherPage.cs index 28a5ed843..b9e58a5af 100644 --- a/src/App/Pages/Vault/VaultEditCipherPage.cs +++ b/src/App/Pages/Vault/VaultEditCipherPage.cs @@ -20,6 +20,7 @@ namespace Bit.App.Pages private readonly ICipherService _cipherService; private readonly IFolderService _folderService; private readonly IUserDialogs _userDialogs; + private readonly IDeviceActionService _deviceActionService; private readonly IConnectivity _connectivity; private readonly IDeviceInfoService _deviceInfo; private readonly IGoogleAnalyticsService _googleAnalyticsService; @@ -31,6 +32,7 @@ namespace Bit.App.Pages _cipherService = Resolver.Resolve(); _folderService = Resolver.Resolve(); _userDialogs = Resolver.Resolve(); + _deviceActionService = Resolver.Resolve(); _connectivity = Resolver.Resolve(); _deviceInfo = Resolver.Resolve(); _googleAnalyticsService = Resolver.Resolve(); @@ -618,7 +620,7 @@ namespace Bit.App.Pages if(saveTask.Succeeded) { - _userDialogs.Toast(AppResources.ItemUpdated); + _deviceActionService.Toast(AppResources.ItemUpdated); _googleAnalyticsService.TrackAppEvent("EditedCipher"); await Navigation.PopForDeviceAsync(); } @@ -804,7 +806,7 @@ namespace Bit.App.Pages if(!string.IsNullOrWhiteSpace(key)) { LoginTotpCell.Entry.Text = key; - _userDialogs.Toast(AppResources.AuthenticatorKeyAdded); + _deviceActionService.Toast(AppResources.AuthenticatorKeyAdded); } else { @@ -827,7 +829,7 @@ namespace Bit.App.Pages var page = new ToolsPasswordGeneratorPage((password) => { LoginPasswordCell.Entry.Text = password; - _userDialogs.Toast(AppResources.PasswordGenerated); + _deviceActionService.Toast(AppResources.PasswordGenerated); }); await Navigation.PushForDeviceAsync(page); } @@ -863,7 +865,7 @@ namespace Bit.App.Pages if(deleteTask.Succeeded) { - _userDialogs.Toast(AppResources.ItemDeleted); + _deviceActionService.Toast(AppResources.ItemDeleted); _googleAnalyticsService.TrackAppEvent("DeletedCipher"); await Navigation.PopForDeviceAsync(); } diff --git a/src/App/Pages/Vault/VaultViewCipherPage.cs b/src/App/Pages/Vault/VaultViewCipherPage.cs index 046b05bf7..a5f6fc011 100644 --- a/src/App/Pages/Vault/VaultViewCipherPage.cs +++ b/src/App/Pages/Vault/VaultViewCipherPage.cs @@ -475,7 +475,7 @@ namespace Bit.App.Pages private void Copy(string copyText, string alertLabel) { _deviceActionService.CopyToClipboard(copyText); - _userDialogs.Toast(string.Format(AppResources.ValueHasBeenCopied, alertLabel)); + _deviceActionService.Toast(string.Format(AppResources.ValueHasBeenCopied, alertLabel)); } private void TotpTick(string totpKey) diff --git a/src/App/Services/AuthService.cs b/src/App/Services/AuthService.cs index b4902d17d..272165889 100644 --- a/src/App/Services/AuthService.cs +++ b/src/App/Services/AuthService.cs @@ -223,7 +223,7 @@ namespace Bit.App.Services Device.BeginInvokeOnMainThread(() => Application.Current.MainPage = new ExtendedNavigationPage(new HomePage())); if(!string.IsNullOrWhiteSpace(logoutMessage)) { - Resolver.Resolve()?.Toast(logoutMessage); + Resolver.Resolve()?.Toast(logoutMessage); } } diff --git a/src/App/Utilities/Helpers.cs b/src/App/Utilities/Helpers.cs index 39007f876..16eeae134 100644 --- a/src/App/Utilities/Helpers.cs +++ b/src/App/Utilities/Helpers.cs @@ -157,8 +157,9 @@ namespace Bit.App.Utilities public static void CipherCopy(string copyText, string alertLabel) { - Resolver.Resolve().CopyToClipboard(copyText); - Resolver.Resolve().Toast(string.Format(AppResources.ValueHasBeenCopied, alertLabel)); + var daService = Resolver.Resolve(); + daService.CopyToClipboard(copyText); + daService.Toast(string.Format(AppResources.ValueHasBeenCopied, alertLabel)); } public static async void AddCipher(Page page, string folderId) diff --git a/src/UWP/Services/DeviceActionService.cs b/src/UWP/Services/DeviceActionService.cs index cbee7ae23..024be3f43 100644 --- a/src/UWP/Services/DeviceActionService.cs +++ b/src/UWP/Services/DeviceActionService.cs @@ -1,5 +1,6 @@ using Bit.App.Abstractions; using Bit.App.Models.Page; +using Coding4Fun.Toolkit.Controls; using System; using System.Linq; using System.Runtime.InteropServices.WindowsRuntime; @@ -8,8 +9,10 @@ using Windows.ApplicationModel.Core; using Windows.ApplicationModel.DataTransfer; using Windows.Storage; using Windows.System; +using Windows.UI; using Windows.UI.Core; -using Xamarin.Forms; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Media; namespace Bit.UWP.Services { @@ -78,7 +81,7 @@ namespace Bit.UWP.Services private async Task SelectFileResult(StorageFile file) { var buffer = await FileIO.ReadBufferAsync(file); - MessagingCenter.Send(Application.Current, "SelectFileResult", + Xamarin.Forms.MessagingCenter.Send(Xamarin.Forms.Application.Current, "SelectFileResult", new Tuple(buffer.ToArray(), file.Name)); } @@ -121,5 +124,24 @@ namespace Bit.UWP.Services { throw new NotImplementedException(); } + + public void Toast(string text, bool longDuration = false) + { + new ToastPrompt + { + Message = text, + TextWrapping = TextWrapping.Wrap, + MillisecondsUntilHidden = Convert.ToInt32(longDuration ? 5 : 2) * 1000, + Background = new SolidColorBrush(Color.FromArgb(255, 73, 73, 73)), + Foreground = new SolidColorBrush(Colors.White), + Margin = new Thickness(0, 0, 0, 100), + HorizontalAlignment = HorizontalAlignment.Center, + VerticalAlignment = VerticalAlignment.Bottom, + HorizontalContentAlignment = HorizontalAlignment.Center, + VerticalContentAlignment = VerticalAlignment.Center, + Stretch = Stretch.Uniform, + IsHitTestVisible = false + }.Show(); + } } } diff --git a/src/UWP/UWP.csproj b/src/UWP/UWP.csproj index ebd2b2ff2..a0a200fa6 100644 --- a/src/UWP/UWP.csproj +++ b/src/UWP/UWP.csproj @@ -192,7 +192,7 @@ 6.0.5 - 2.1.0 + 2.1.1 4.0.12 diff --git a/src/iOS/Services/DeviceActionService.cs b/src/iOS/Services/DeviceActionService.cs index db198479d..f1c592449 100644 --- a/src/iOS/Services/DeviceActionService.cs +++ b/src/iOS/Services/DeviceActionService.cs @@ -26,6 +26,16 @@ namespace Bit.iOS.Services _deviceInfoService = deviceInfoService; } + public void Toast(string text, bool longDuration = false) + { + var snackbar = new TTGSnackBar.TTGSnackbar(text) + { + Duration = TimeSpan.FromSeconds(longDuration ? 5 : 2), + AnimationType = TTGSnackBar.TTGSnackbarAnimationType.FadeInFadeOut + }; + snackbar.Show(); + } + public void CopyToClipboard(string text) { UIPasteboard clipboard = UIPasteboard.General; diff --git a/src/iOS/iOS.csproj b/src/iOS/iOS.csproj index 2d3e70ea8..39fa2d3d3 100644 --- a/src/iOS/iOS.csproj +++ b/src/iOS/iOS.csproj @@ -704,6 +704,9 @@ 4.0.12 + + 1.3.4 + 3.17.0.1