From 68a85a25610b6f0aa09c4ffe90ff2224690ffed2 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Thu, 30 May 2019 22:05:50 -0400 Subject: [PATCH] myvault tile service --- src/Android/Android.csproj | 1 + src/Android/Tile/MyVaultTileService.cs | 68 ++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 src/Android/Tile/MyVaultTileService.cs diff --git a/src/Android/Android.csproj b/src/Android/Android.csproj index b7a6e444d..71b0b448b 100644 --- a/src/Android/Android.csproj +++ b/src/Android/Android.csproj @@ -141,6 +141,7 @@ + diff --git a/src/Android/Tile/MyVaultTileService.cs b/src/Android/Tile/MyVaultTileService.cs new file mode 100644 index 000000000..535abf830 --- /dev/null +++ b/src/Android/Tile/MyVaultTileService.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/MyVault", + Icon = "@drawable/shield")] + [IntentFilter(new string[] { ActionQsTile })] + [Register("com.x8bit.bitwarden.Tile.MyVaultTileService")] + 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); + } + } +}