From 5950c33a43d4ba4a05d6bc52554fcbf2f83a6855 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Tue, 19 Sep 2017 15:55:15 -0400 Subject: [PATCH] qs tile to quickly launch my vault (android) --- src/Android/Android.csproj | 6 ++- src/Android/AutofillService.cs | 2 +- src/Android/MainActivity.cs | 1 + src/Android/MyVaultTileService.cs | 58 +++++++++++++++++++++ src/Android/Resources/Resource.Designer.cs | 28 ++++++---- src/Android/Resources/drawable/shield.png | Bin 0 -> 2298 bytes src/Android/Resources/values/strings.xml | 3 ++ src/Android/SplashActivity.cs | 8 +-- src/App/App.cs | 3 +- src/App/Pages/MainPage.cs | 4 +- src/iOS/AppDelegate.cs | 1 + test/Android.Test/Android.Test.csproj | 2 +- 12 files changed, 96 insertions(+), 20 deletions(-) create mode 100644 src/Android/MyVaultTileService.cs create mode 100644 src/Android/Resources/drawable/shield.png diff --git a/src/Android/Android.csproj b/src/Android/Android.csproj index b18fd4dd5..c2f1a3de5 100644 --- a/src/Android/Android.csproj +++ b/src/Android/Android.csproj @@ -17,7 +17,7 @@ Off Properties\AndroidManifest.xml True - v7.1 + v8.0 armeabi,armeabi-v7a,x86 Xamarin.Android.Net.AndroidClientHandler @@ -308,6 +308,7 @@ + @@ -944,6 +945,9 @@ + + + diff --git a/src/Android/AutofillService.cs b/src/Android/AutofillService.cs index 93f7def90..cc0fa0020 100644 --- a/src/Android/AutofillService.cs +++ b/src/Android/AutofillService.cs @@ -11,7 +11,7 @@ using XLabs.Ioc; namespace Bit.Android { - [Service(Permission = "android.permission.BIND_ACCESSIBILITY_SERVICE", Label = "bitwarden")] + [Service(Permission = global::Android.Manifest.Permission.BindAccessibilityService, Label = "bitwarden")] [IntentFilter(new string[] { "android.accessibilityservice.AccessibilityService" })] [MetaData("android.accessibilityservice", Resource = "@xml/accessibilityservice")] public class AutofillService : AccessibilityService diff --git a/src/Android/MainActivity.cs b/src/Android/MainActivity.cs index 430512b6d..124466205 100644 --- a/src/Android/MainActivity.cs +++ b/src/Android/MainActivity.cs @@ -74,6 +74,7 @@ namespace Bit.Android _settings = Resolver.Resolve(); LoadApplication(new App.App( uri, + Intent.GetBooleanExtra("myVaultTile", false), Resolver.Resolve(), Resolver.Resolve(), Resolver.Resolve(), diff --git a/src/Android/MyVaultTileService.cs b/src/Android/MyVaultTileService.cs new file mode 100644 index 000000000..a430b12fb --- /dev/null +++ b/src/Android/MyVaultTileService.cs @@ -0,0 +1,58 @@ +using Android.App; +using Android.Content; +using Android.Service.QuickSettings; +using Java.Lang; + +namespace Bit.Android +{ + [Service(Permission = global::Android.Manifest.Permission.BindQuickSettingsTile, + Label = "@string/MyVault", Icon = "@drawable/shield")] + [IntentFilter(new string[] { ActionQsTile })] + public class MyVaultTileService : 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(SplashActivity)); + intent.SetFlags(ActivityFlags.NewTask | ActivityFlags.SingleTop | ActivityFlags.ClearTop); + intent.PutExtra("myVaultTile", true); + StartActivityAndCollapse(intent); + } + } +} diff --git a/src/Android/Resources/Resource.Designer.cs b/src/Android/Resources/Resource.Designer.cs index f70ef35ee..4ed63b046 100644 --- a/src/Android/Resources/Resource.Designer.cs +++ b/src/Android/Resources/Resource.Designer.cs @@ -2769,8 +2769,8 @@ namespace Bit.Android // aapt resource value: 0x7f0200e7 public const int notification_sm = 2130837735; - // aapt resource value: 0x7f0200f9 - public const int notification_template_icon_bg = 2130837753; + // aapt resource value: 0x7f0200fa + public const int notification_template_icon_bg = 2130837754; // aapt resource value: 0x7f0200e8 public const int paperclip = 2130837736; @@ -2797,31 +2797,34 @@ namespace Bit.Android public const int share_tools = 2130837743; // aapt resource value: 0x7f0200f0 - public const int splash_screen = 2130837744; + public const int shield = 2130837744; // aapt resource value: 0x7f0200f1 - public const int star = 2130837745; + public const int splash_screen = 2130837745; // aapt resource value: 0x7f0200f2 - public const int star_selected = 2130837746; + public const int star = 2130837746; // aapt resource value: 0x7f0200f3 - public const int tools = 2130837747; + public const int star_selected = 2130837747; // aapt resource value: 0x7f0200f4 - public const int tools_selected = 2130837748; + public const int tools = 2130837748; // aapt resource value: 0x7f0200f5 - public const int trash = 2130837749; + public const int tools_selected = 2130837749; // aapt resource value: 0x7f0200f6 - public const int upload = 2130837750; + public const int trash = 2130837750; // aapt resource value: 0x7f0200f7 - public const int user = 2130837751; + public const int upload = 2130837751; // aapt resource value: 0x7f0200f8 - public const int yubikey = 2130837752; + public const int user = 2130837752; + + // aapt resource value: 0x7f0200f9 + public const int yubikey = 2130837753; static Drawable() { @@ -3756,6 +3759,9 @@ namespace Bit.Android // aapt resource value: 0x7f080046 public const int Hello = 2131230790; + // aapt resource value: 0x7f08009a + public const int MyVault = 2131230874; + // aapt resource value: 0x7f08002e public const int abc_action_bar_home_description = 2131230766; diff --git a/src/Android/Resources/drawable/shield.png b/src/Android/Resources/drawable/shield.png new file mode 100644 index 0000000000000000000000000000000000000000..68d828f12feb8eace975b30fdcf28c0f9e75d460 GIT binary patch literal 2298 zcmeHHSy++@8~p&c$gLDJ+qB$LEYmU=HQWtRG-Z(}MJ3Z*QgP1#^8dl#GBXR!+*32O zk^!|aN2$rC(MCn5)g?!Bo6*57TnHHFe(vXD{&Vxb=RD`;yw7vq+yJb%7Ssp|0DukCfHqeUpaIz&F%N=qn`9}#7w5T2|Brvw1%&VJX>10rOAf>a0U$6$MO95*V+(Yv zrk1vj?zZiE`Y?kXhDN*g?A>R)|A3jfg{3vz=8)|X`=buW5#KmEIiEnexVd|HdU>OL zFus0R|A0Uoff!68pE(;68Ws_GJ}NpUHtu3VA}u97<5Cu#!DO-jmwPoY|N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T+P7M_EO`Jhjn)7kuOS;aw*WN=Ck6`v6Xc=hh*^WqGa~78xh6{ sYj;;>r8_-2jGnyH(57WQAXaEFAdH5YLq)8gM*jMdXiu!iBR5L+pLfdo761SM literal 0 HcmV?d00001 diff --git a/src/Android/Resources/values/strings.xml b/src/Android/Resources/values/strings.xml index 4220f86af..bdd7c583e 100644 --- a/src/Android/Resources/values/strings.xml +++ b/src/Android/Resources/values/strings.xml @@ -5,4 +5,7 @@ accessibility service by tapping the toggle switch above, then press OK on the confirmation pop-up. You can then press the back button twice to return to the main bitwarden app. + + My Vault + diff --git a/src/Android/SplashActivity.cs b/src/Android/SplashActivity.cs index ea1c1b4fd..4dfb8acfb 100644 --- a/src/Android/SplashActivity.cs +++ b/src/Android/SplashActivity.cs @@ -7,8 +7,8 @@ using System.Threading.Tasks; namespace Bit.Android { - [Activity(Theme = "@style/BitwardenTheme.Splash", - MainLauncher = true, + [Activity(Theme = "@style/BitwardenTheme.Splash", + MainLauncher = true, NoHistory = true, WindowSoftInputMode = global::Android.Views.SoftInput.StateHidden)] public class SplashActivity : AppCompatActivity @@ -23,7 +23,9 @@ namespace Bit.Android base.OnResume(); var startupWork = new Task(() => { - StartActivity(new Intent(Application.Context, typeof(MainActivity))); + var mainIntent = new Intent(Application.Context, typeof(MainActivity)); + mainIntent.PutExtra("myVaultTile", Intent.GetBooleanExtra("myVaultTile", false)); + StartActivity(mainIntent); }); startupWork.Start(); diff --git a/src/App/App.cs b/src/App/App.cs index 64f6de8d6..c946660e8 100644 --- a/src/App/App.cs +++ b/src/App/App.cs @@ -35,6 +35,7 @@ namespace Bit.App public App( string uri, + bool myVault, IAuthService authService, IConnectivity connectivity, IUserDialogs userDialogs, @@ -71,7 +72,7 @@ namespace Bit.App } else if(authService.IsAuthenticated) { - MainPage = new MainPage(); + MainPage = new MainPage(myVault: myVault); } else { diff --git a/src/App/Pages/MainPage.cs b/src/App/Pages/MainPage.cs index 50f686ae3..e6e16d206 100644 --- a/src/App/Pages/MainPage.cs +++ b/src/App/Pages/MainPage.cs @@ -7,7 +7,7 @@ namespace Bit.App.Pages { public class MainPage : ExtendedTabbedPage { - public MainPage(string uri = null) + public MainPage(string uri = null, bool myVault = false) { TintColor = Color.FromHex("3c8dbc"); @@ -33,7 +33,7 @@ namespace Bit.App.Pages Children.Add(toolsNavigation); Children.Add(settingsNavigation); - if(uri != null) + if(myVault || uri != null) { SelectedItem = vaultNavigation; } diff --git a/src/iOS/AppDelegate.cs b/src/iOS/AppDelegate.cs index 6e31ee15e..bd3bda698 100644 --- a/src/iOS/AppDelegate.cs +++ b/src/iOS/AppDelegate.cs @@ -59,6 +59,7 @@ namespace Bit.iOS LoadApplication(new App.App( null, + false, Resolver.Resolve(), Resolver.Resolve(), Resolver.Resolve(), diff --git a/test/Android.Test/Android.Test.csproj b/test/Android.Test/Android.Test.csproj index 71d563072..b491f0b1e 100644 --- a/test/Android.Test/Android.Test.csproj +++ b/test/Android.Test/Android.Test.csproj @@ -16,7 +16,7 @@ Resources\Resource.Designer.cs Off True - v7.1 + v8.0 Properties\AndroidManifest.xml