diff --git a/src/Android/Accessibility/AccessibilityService.cs b/src/Android/Accessibility/AccessibilityService.cs index ccee0bd92..3af298bf7 100644 --- a/src/Android/Accessibility/AccessibilityService.cs +++ b/src/Android/Accessibility/AccessibilityService.cs @@ -231,7 +231,7 @@ namespace Bit.Droid.Accessibility AppResources.BitwardenAutofillServiceNotificationContentOld; var builder = new Notification.Builder(this); - builder.SetSmallIcon(Resource.Drawable.notification_sm) + builder.SetSmallIcon(Resource.Drawable.shield) .SetContentTitle(AppResources.BitwardenAutofillService) .SetContentText(notificationContent) .SetTicker(notificationContent) diff --git a/src/Android/Android.csproj b/src/Android/Android.csproj index 4bfa1d1b6..b96b14bef 100644 --- a/src/Android/Android.csproj +++ b/src/Android/Android.csproj @@ -133,7 +133,8 @@ - + + @@ -395,9 +396,6 @@ - - - @@ -443,18 +441,6 @@ - - - - - - - - - - - - @@ -539,5 +525,32 @@ Designer + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Android/MainActivity.cs b/src/Android/MainActivity.cs index ffce1caff..9b98ff7d5 100644 --- a/src/Android/MainActivity.cs +++ b/src/Android/MainActivity.cs @@ -143,7 +143,18 @@ namespace Bit.Droid protected override void OnNewIntent(Intent intent) { base.OnNewIntent(intent); - ParseYubiKey(intent.DataString); + if(intent.GetBooleanExtra("generatorTile", false)) + { + _messagingService.Send("popAllAndGoToTabGenerator"); + } + if(intent.GetBooleanExtra("myVaultTile", false)) + { + _messagingService.Send("popAllAndGoToTabMyVault"); + } + else + { + ParseYubiKey(intent.DataString); + } } public async override void OnRequestPermissionsResult(int requestCode, string[] permissions, @@ -243,6 +254,7 @@ namespace Bit.Droid { Uri = Intent.GetStringExtra("uri") ?? Intent.GetStringExtra("autofillFrameworkUri"), MyVaultTile = Intent.GetBooleanExtra("myVaultTile", false), + GeneratorTile = Intent.GetBooleanExtra("generatorTile", false), FromAutofillFramework = Intent.GetBooleanExtra("autofillFramework", false) }; var fillType = Intent.GetIntExtra("autofillFrameworkFillType", 0); diff --git a/src/Android/Resources/Resource.designer.cs b/src/Android/Resources/Resource.designer.cs index 5c452b9b3..306673134 100644 --- a/src/Android/Resources/Resource.designer.cs +++ b/src/Android/Resources/Resource.designer.cs @@ -9031,29 +9031,29 @@ namespace Bit.Droid // aapt resource value: 0x7f020155 public const int notification_icon_background = 2130837845; - // aapt resource value: 0x7f020156 - public const int notification_sm = 2130837846; - // aapt resource value: 0x7f020164 public const int notification_template_icon_bg = 2130837860; // aapt resource value: 0x7f020165 public const int notification_template_icon_low_bg = 2130837861; + // aapt resource value: 0x7f020156 + public const int notification_tile_bg = 2130837846; + // aapt resource value: 0x7f020157 - public const int notification_tile_bg = 2130837847; + public const int notify_panel_notification_icon_bg = 2130837847; // aapt resource value: 0x7f020158 - public const int notify_panel_notification_icon_bg = 2130837848; + public const int pencil = 2130837848; // aapt resource value: 0x7f020159 - public const int pencil = 2130837849; + public const int plus = 2130837849; // aapt resource value: 0x7f02015a - public const int plus = 2130837850; + public const int refresh = 2130837850; // aapt resource value: 0x7f02015b - public const int refresh = 2130837851; + public const int refresh_sm = 2130837851; // aapt resource value: 0x7f02015c public const int search = 2130837852; @@ -10483,6 +10483,9 @@ namespace Bit.Droid // aapt resource value: 0x7f0900c2 public const int MyVault = 2131296450; + // aapt resource value: 0x7f0900c3 + public const int PasswordGenerator = 2131296451; + // aapt resource value: 0x7f090032 public const int abc_action_bar_home_description = 2131296306; diff --git a/src/Android/Resources/drawable-hdpi/notification_sm.png b/src/Android/Resources/drawable-hdpi/notification_sm.png deleted file mode 100644 index a893ed8bf..000000000 Binary files a/src/Android/Resources/drawable-hdpi/notification_sm.png and /dev/null differ diff --git a/src/Android/Resources/drawable-hdpi/refresh_sm.png b/src/Android/Resources/drawable-hdpi/refresh_sm.png new file mode 100644 index 000000000..172499a19 Binary files /dev/null and b/src/Android/Resources/drawable-hdpi/refresh_sm.png differ diff --git a/src/Android/Resources/drawable-hdpi/shield.png b/src/Android/Resources/drawable-hdpi/shield.png new file mode 100644 index 000000000..cb08cd858 Binary files /dev/null and b/src/Android/Resources/drawable-hdpi/shield.png differ diff --git a/src/Android/Resources/drawable-xhdpi/notification_sm.png b/src/Android/Resources/drawable-xhdpi/notification_sm.png deleted file mode 100644 index dc65e1730..000000000 Binary files a/src/Android/Resources/drawable-xhdpi/notification_sm.png and /dev/null differ diff --git a/src/Android/Resources/drawable-xhdpi/refresh_sm.png b/src/Android/Resources/drawable-xhdpi/refresh_sm.png new file mode 100644 index 000000000..e918e245a Binary files /dev/null and b/src/Android/Resources/drawable-xhdpi/refresh_sm.png differ diff --git a/src/Android/Resources/drawable-xhdpi/shield.png b/src/Android/Resources/drawable-xhdpi/shield.png new file mode 100644 index 000000000..4335f98f9 Binary files /dev/null and b/src/Android/Resources/drawable-xhdpi/shield.png differ diff --git a/src/Android/Resources/drawable-xxhdpi/notification_sm.png b/src/Android/Resources/drawable-xxhdpi/notification_sm.png deleted file mode 100644 index 5d21ebb89..000000000 Binary files a/src/Android/Resources/drawable-xxhdpi/notification_sm.png and /dev/null differ diff --git a/src/Android/Resources/drawable-xxhdpi/refresh_sm.png b/src/Android/Resources/drawable-xxhdpi/refresh_sm.png new file mode 100644 index 000000000..8beb7fd56 Binary files /dev/null and b/src/Android/Resources/drawable-xxhdpi/refresh_sm.png differ diff --git a/src/Android/Resources/drawable-xxhdpi/shield.png b/src/Android/Resources/drawable-xxhdpi/shield.png new file mode 100644 index 000000000..be79eb5ec Binary files /dev/null and b/src/Android/Resources/drawable-xxhdpi/shield.png differ diff --git a/src/Android/Resources/drawable-xxxhdpi/notification_sm.png b/src/Android/Resources/drawable-xxxhdpi/notification_sm.png deleted file mode 100644 index 760eff254..000000000 Binary files a/src/Android/Resources/drawable-xxxhdpi/notification_sm.png and /dev/null differ diff --git a/src/Android/Resources/drawable-xxxhdpi/refresh_sm.png b/src/Android/Resources/drawable-xxxhdpi/refresh_sm.png new file mode 100644 index 000000000..46ec1d43f Binary files /dev/null and b/src/Android/Resources/drawable-xxxhdpi/refresh_sm.png differ diff --git a/src/Android/Resources/drawable-xxxhdpi/shield.png b/src/Android/Resources/drawable-xxxhdpi/shield.png new file mode 100644 index 000000000..98de1da5f Binary files /dev/null and b/src/Android/Resources/drawable-xxxhdpi/shield.png differ diff --git a/src/Android/Resources/drawable/notification_sm.png b/src/Android/Resources/drawable/notification_sm.png deleted file mode 100644 index 86b7c130a..000000000 Binary files a/src/Android/Resources/drawable/notification_sm.png and /dev/null differ diff --git a/src/Android/Resources/drawable/refresh_sm.png b/src/Android/Resources/drawable/refresh_sm.png new file mode 100644 index 000000000..4516f067e Binary files /dev/null and b/src/Android/Resources/drawable/refresh_sm.png differ diff --git a/src/Android/Resources/drawable/shield.png b/src/Android/Resources/drawable/shield.png index 68d828f12..3d7981449 100644 Binary files a/src/Android/Resources/drawable/shield.png and b/src/Android/Resources/drawable/shield.png differ diff --git a/src/Android/Resources/values-v21/styles.xml b/src/Android/Resources/values-v21/styles.xml index 780d00f0b..9eb2dac4c 100644 --- a/src/Android/Resources/values-v21/styles.xml +++ b/src/Android/Resources/values-v21/styles.xml @@ -6,4 +6,6 @@ + diff --git a/src/Android/Resources/values/strings.xml b/src/Android/Resources/values/strings.xml index 7c8d5d2fd..6fb45f3c3 100644 --- a/src/Android/Resources/values/strings.xml +++ b/src/Android/Resources/values/strings.xml @@ -13,4 +13,7 @@ My Vault + + Password Generator + diff --git a/src/Android/Tiles/GeneratorTileService.cs b/src/Android/Tiles/GeneratorTileService.cs new file mode 100644 index 000000000..ce03d1f31 --- /dev/null +++ b/src/Android/Tiles/GeneratorTileService.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Android.App; +using Android.Content; +using Android.OS; +using Android.Runtime; +using Android.Service.QuickSettings; +using Android.Views; +using Android.Widget; +using Java.Lang; + +namespace Bit.Droid.Tile +{ + [Service(Permission = Android.Manifest.Permission.BindQuickSettingsTile, Label = "@string/PasswordGenerator", + Icon = "@drawable/refresh_sm")] + [IntentFilter(new string[] { ActionQsTile })] + [Register("com.x8bit.bitwarden.GeneratorTileService")] + public class GeneratorTileService : TileService + { + public override void OnTileAdded() + { + base.OnTileAdded(); + } + + public override void OnStartListening() + { + base.OnStartListening(); + } + + public override void OnStopListening() + { + base.OnStopListening(); + } + + public override void OnTileRemoved() + { + base.OnTileRemoved(); + } + + public override void OnClick() + { + base.OnClick(); + + if(IsLocked) + { + UnlockAndRun(new Runnable(() => + { + LaunchMyVault(); + })); + } + else + { + LaunchMyVault(); + } + } + + private void LaunchMyVault() + { + var intent = new Intent(this, typeof(MainActivity)); + intent.SetFlags(ActivityFlags.NewTask | ActivityFlags.SingleTop | ActivityFlags.ClearTop); + intent.PutExtra("generatorTile", true); + StartActivityAndCollapse(intent); + } + } +} diff --git a/src/Android/Tile/MyVaultTileService.cs b/src/Android/Tiles/MyVaultTileService.cs similarity index 96% rename from src/Android/Tile/MyVaultTileService.cs rename to src/Android/Tiles/MyVaultTileService.cs index 56b74585b..bef831100 100644 --- a/src/Android/Tile/MyVaultTileService.cs +++ b/src/Android/Tiles/MyVaultTileService.cs @@ -17,7 +17,7 @@ namespace Bit.Droid.Tile [Service(Permission = Android.Manifest.Permission.BindQuickSettingsTile, Label = "@string/MyVault", Icon = "@drawable/shield")] [IntentFilter(new string[] { ActionQsTile })] - [Register("com.x8bit.bitwarden.Tile.MyVaultTileService")] + [Register("com.x8bit.bitwarden.MyVaultTileService")] public class MyVaultTileService : TileService { public override void OnTileAdded() diff --git a/src/App/App.xaml.cs b/src/App/App.xaml.cs index eb8fd6520..240b6f288 100644 --- a/src/App/App.xaml.cs +++ b/src/App/App.xaml.cs @@ -122,6 +122,28 @@ namespace Bit.App 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") + { + tabsPage.ResetToVaultPage(); + } + else + { + tabsPage.ResetToGeneratorPage(); + } + } + }); + } }); } @@ -214,7 +236,7 @@ namespace Bit.App } else { - Current.MainPage = new TabsPage(); + Current.MainPage = new TabsPage(_appOptions); } } else diff --git a/src/App/Models/AppOptions.cs b/src/App/Models/AppOptions.cs index 43648b00a..8469f4957 100644 --- a/src/App/Models/AppOptions.cs +++ b/src/App/Models/AppOptions.cs @@ -5,6 +5,7 @@ namespace Bit.App.Models public class AppOptions { public bool MyVaultTile { get; set; } + public bool GeneratorTile { get; set; } public bool FromAutofillFramework { get; set; } public CipherType? FillType { get; set; } public string Uri { get; set; } diff --git a/src/App/Pages/TabsPage.cs b/src/App/Pages/TabsPage.cs index 67fbb38c2..d0f07c999 100644 --- a/src/App/Pages/TabsPage.cs +++ b/src/App/Pages/TabsPage.cs @@ -1,5 +1,8 @@ using Bit.App.Effect; +using Bit.App.Models; using Bit.App.Resources; +using Bit.Core.Abstractions; +using Bit.Core.Utilities; using Xamarin.Forms; namespace Bit.App.Pages @@ -7,8 +10,9 @@ namespace Bit.App.Pages public class TabsPage : TabbedPage { private NavigationPage _groupingsPage; + private NavigationPage _generatorPage; - public TabsPage() + public TabsPage(AppOptions appOptions = null) { _groupingsPage = new NavigationPage(new GroupingsPage(true)) { @@ -17,12 +21,12 @@ namespace Bit.App.Pages }; Children.Add(_groupingsPage); - var generatorPage = new NavigationPage(new GeneratorPage(true, null, this)) + _generatorPage = new NavigationPage(new GeneratorPage(true, null, this)) { Title = AppResources.Generator, Icon = "refresh.png" }; - Children.Add(generatorPage); + Children.Add(_generatorPage); var settingsPage = new NavigationPage(new SettingsPage(this)) { @@ -44,6 +48,12 @@ namespace Bit.App.Pages Xamarin.Forms.PlatformConfiguration.AndroidSpecific.TabbedPage.SetBarItemColor(this, (Color)Application.Current.Resources["TabBarItemColor"]); } + + if(appOptions?.GeneratorTile ?? false) + { + appOptions.GeneratorTile = false; + ResetToGeneratorPage(); + } } public void ResetToVaultPage() @@ -51,6 +61,11 @@ namespace Bit.App.Pages CurrentPage = _groupingsPage; } + public void ResetToGeneratorPage() + { + CurrentPage = _generatorPage; + } + protected async override void OnCurrentPageChanged() { if(CurrentPage is NavigationPage navPage)