From 64fd8e3be92d9a4428ba924e25e87577ec1e8ffd Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Sat, 28 Jan 2017 23:58:26 -0500 Subject: [PATCH] autofill service WIP --- src/Android/Android.csproj | 15 +++++++++ src/Android/AutofillActivity.cs | 1 + src/Android/AutofillService.cs | 25 ++------------ src/Android/Resources/Resource.Designer.cs | 31 ++++++++++-------- .../drawable-hdpi/notification_sm.png | Bin 0 -> 531 bytes .../drawable-xhdpi/notification_sm.png | Bin 0 -> 586 bytes .../drawable-xxhdpi/notification_sm.png | Bin 0 -> 773 bytes .../drawable-xxxhdpi/notification_sm.png | Bin 0 -> 1038 bytes .../Resources/drawable/notification_sm.png | Bin 0 -> 364 bytes 9 files changed, 35 insertions(+), 37 deletions(-) create mode 100644 src/Android/Resources/drawable-hdpi/notification_sm.png create mode 100644 src/Android/Resources/drawable-xhdpi/notification_sm.png create mode 100644 src/Android/Resources/drawable-xxhdpi/notification_sm.png create mode 100644 src/Android/Resources/drawable-xxxhdpi/notification_sm.png create mode 100644 src/Android/Resources/drawable/notification_sm.png diff --git a/src/Android/Android.csproj b/src/Android/Android.csproj index 109b2dcbf..7f25fab87 100644 --- a/src/Android/Android.csproj +++ b/src/Android/Android.csproj @@ -746,6 +746,21 @@ + + + + + + + + + + + + + + + diff --git a/src/Android/AutofillActivity.cs b/src/Android/AutofillActivity.cs index 3022fd963..f35a6eb3d 100644 --- a/src/Android/AutofillActivity.cs +++ b/src/Android/AutofillActivity.cs @@ -22,6 +22,7 @@ namespace Bit.Android _lastQueriedUri = Intent.GetStringExtra("uri"); var intent = new Intent(this, typeof(MainActivity)); + intent.SetFlags(ActivityFlags.NewTask | ActivityFlags.ClearTop); intent.PutExtra("uri", _lastQueriedUri); StartActivityForResult(intent, 123); } diff --git a/src/Android/AutofillService.cs b/src/Android/AutofillService.cs index c79d5a32f..4792159e7 100644 --- a/src/Android/AutofillService.cs +++ b/src/Android/AutofillService.cs @@ -132,36 +132,15 @@ namespace Bit.Android intent.SetFlags(ActivityFlags.NewTask | ActivityFlags.SingleTop | ActivityFlags.ClearTop); var pendingIntent = PendingIntent.GetActivity(this, 0, intent, PendingIntentFlags.UpdateCurrent); - var targetName = uri; - if(uri.StartsWith(AndroidAppProtocol)) - { - var packageName = uri.Substring(AndroidAppProtocol.Length); - try - { - var appInfo = PackageManager.GetApplicationInfo(packageName, 0); - targetName = appInfo != null ? PackageManager.GetApplicationLabel(appInfo) : packageName; - } - catch - { - targetName = packageName; - } - } - else - { - //targetName = KeePassLib.Utility.UrlUtil.GetHost(uri); - } - - var builder = new Notification.Builder(this); - //TODO icon - //TODO plugin icon - builder.SetSmallIcon(Resource.Drawable.icon) + builder.SetSmallIcon(Resource.Drawable.notification_sm) .SetContentText("Tap this notification to autofill a login from your bitwarden vault.") .SetContentTitle("bitwarden Autofill Service") .SetWhen(Java.Lang.JavaSystem.CurrentTimeMillis()) .SetTicker("Tap this notification to autofill a login from your bitwarden vault.") .SetVisibility(NotificationVisibility.Secret) .SetContentIntent(pendingIntent); + var notificationManager = (NotificationManager)GetSystemService(NotificationService); notificationManager.Notify(AutoFillNotificationId, builder.Build()); } diff --git a/src/Android/Resources/Resource.Designer.cs b/src/Android/Resources/Resource.Designer.cs index 80193de6a..074cb2131 100644 --- a/src/Android/Resources/Resource.Designer.cs +++ b/src/Android/Resources/Resource.Designer.cs @@ -2727,41 +2727,44 @@ namespace Bit.Android // aapt resource value: 0x7f0200df public const int mr_ic_play_light = 2130837727; - // aapt resource value: 0x7f0200eb - public const int notification_template_icon_bg = 2130837739; - // aapt resource value: 0x7f0200e0 - public const int plus = 2130837728; + public const int notification_sm = 2130837728; + + // aapt resource value: 0x7f0200ec + public const int notification_template_icon_bg = 2130837740; // aapt resource value: 0x7f0200e1 - public const int refresh = 2130837729; + public const int plus = 2130837729; // aapt resource value: 0x7f0200e2 - public const int roundedbg = 2130837730; + public const int refresh = 2130837730; // aapt resource value: 0x7f0200e3 - public const int roundedbgdark = 2130837731; + public const int roundedbg = 2130837731; // aapt resource value: 0x7f0200e4 - public const int splash_screen = 2130837732; + public const int roundedbgdark = 2130837732; // aapt resource value: 0x7f0200e5 - public const int star = 2130837733; + public const int splash_screen = 2130837733; // aapt resource value: 0x7f0200e6 - public const int star_selected = 2130837734; + public const int star = 2130837734; // aapt resource value: 0x7f0200e7 - public const int tools = 2130837735; + public const int star_selected = 2130837735; // aapt resource value: 0x7f0200e8 - public const int tools_selected = 2130837736; + public const int tools = 2130837736; // aapt resource value: 0x7f0200e9 - public const int upload = 2130837737; + public const int tools_selected = 2130837737; // aapt resource value: 0x7f0200ea - public const int user = 2130837738; + public const int upload = 2130837738; + + // aapt resource value: 0x7f0200eb + public const int user = 2130837739; static Drawable() { diff --git a/src/Android/Resources/drawable-hdpi/notification_sm.png b/src/Android/Resources/drawable-hdpi/notification_sm.png new file mode 100644 index 0000000000000000000000000000000000000000..a893ed8bf551c0c8801d1c9450b7f9b52164810d GIT binary patch literal 531 zcmeAS@N?(olHy`uVBq!ia0vp^Dj>|k3?#4J%UA`Zb_Mu^xB}__LlbiM}x$nTi zqgSurdhqDU+mAng|NWcP%m*~+w5N+>h{fr*myZiI83;5yT)JX~Lf2mLBkOJih*bQ) zKFQ$)C;R$e@taQ9oM~ZZ$a|_~%2uG=esAj06XzWLWEa~!HreMsOF-rFMWr8d5B|Mq zpWx`Ix+UzxrsWIFqAd5E(ct*2Fg+pggoo2@lbWY4PG>I0zDeq^QdzRlwRJ_VnC``# z4Td2*mJ4ilTYR^v!qm8N$!2ptg_$|WF1&c_>+GR^kLk*ly_a7(n$% Ag#Z8m literal 0 HcmV?d00001 diff --git a/src/Android/Resources/drawable-xhdpi/notification_sm.png b/src/Android/Resources/drawable-xhdpi/notification_sm.png new file mode 100644 index 0000000000000000000000000000000000000000..dc65e1730503f1ce4961fe4c13d0edbf8d9af5b1 GIT binary patch literal 586 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA3?vioaBc-sdjotzT!HleAq%>y_vHXRU{@04 z7tFxK%)-jXAu28*Evu%ksim!}XJ~He>=GIo8<&!vk(r&7Us&JKKWX}`t=o6*+OzNY znRDlF-Ffir#mm>%N~-_f^YJ4fTOCZzbpH5E`cbw}+f!|80Qc4n zj*1&NjT;=E=g#&+?YoyLFX+w(pSF3?JgI(?U$ZyKBBb30ofhbH~I zDrkK!VXwSJ5a)N+2J>*O&Hv9GZ~ViZTJ?ebh_{4gkMbvHU`Q}{y85}Sb4q9e01d@q A_W%F@ literal 0 HcmV?d00001 diff --git a/src/Android/Resources/drawable-xxhdpi/notification_sm.png b/src/Android/Resources/drawable-xxhdpi/notification_sm.png new file mode 100644 index 0000000000000000000000000000000000000000..5d21ebb892c6258c5b3ec5e2ee51e3fa0efb8dfd GIT binary patch literal 773 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY3?!3`olAk#s{o%6S0Md=WPtAKz3f2W`j!Ow z1v4-*F|)97a0`h_$tbI+YG~`~>08^_IygExySRFJ`}#%3CMIPTSJrfPPnkYz_Tpu$ zR2M-@Te&*cy%U7@8eDU)2+mD}r{{9guQ^i$Z?=|KG=d;nI{PDhH3hk=}jAd}h!oo&zeZ$HP7M zb6By)o3ct3O;K!btNEJoB7Wh*vmMJBLJxGTRpia|aF)6>q0NM)XX(QJmln%jFEsgL zEE~J4ZhEVS!L5>db?&w7k9F@(Pg$5`FzrQMv>4aAt@~ZSFH_kf+2@v1IiWeO`K{f) zlqC!P7Mwnl%gmYaReOfrbN<;=8{`gap5AddCUJ$3o?c?j0`^50R?aU`VBj@;QD9~= zgKtf|poaZx+iqUh^JiN1lxpSngorynQ40#+$#HRQ`2*p_{^#BA%*^FRxD* zID1dy;Y*WStrctJuD^_&z^Pe0$EYzSNSE!hm!snIxSo&a7Kp9(vn=I4<#|5ud7aeh v78!rJr|&oqPEy?2Xn#WYtk1qWrTkyaS8vIL?TMNSO7IMxu6{1-oD!M<9wgAx literal 0 HcmV?d00001 diff --git a/src/Android/Resources/drawable-xxxhdpi/notification_sm.png b/src/Android/Resources/drawable-xxxhdpi/notification_sm.png new file mode 100644 index 0000000000000000000000000000000000000000..760eff254f92b4a56f2c7a1bb40b2a677444d9cc GIT binary patch literal 1038 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD3?#3*wF4y>?E-v4T!GyGqk!BH*pg7i0}R2; zk|4ie21X`k7FITP4o+@9ej#B|NhxU=Svh$HMI~i5bq!4|Z5>@beFH0NTRVFvH&3s? zkeJxG%$)q<((;PR>YDnd&c6PMQ>QOpx?=U(_1kytJ8r1oWFSa`mHMBZ*N3~-*S*(d!V1elo!&SeKlyhSfTjZTdO=) z@5s)+>#BNc(v$!H8TG5GW~8J|y1BvpbKJA)neCH%EgAlFZ_TXEO3IIHIIdOsD#)lX z;c)OwUYQM3nNnpwTybNT`q6*jv#4#U=mD+^#Y-7^GaQ(uE;O*2EPyf(NHeapDY(00 z=Z`DX*jM#RJ>*{*oq50^%lyZW2q_PRt;sciVx?v{WZnPpagND`wkyv*6naTjxMaQm zSm-16qvKkVLeYIrZ=KT&F$%m?Y*nMb?=*?u%l>w4n1p5;QEv-jR9 z`Gtx+63a85Pb!nTeCWWc^^=#~%Y5E+V9)wb?f-PXbuuRZ^Qu1~{dYNsLBw~{GN)_p z6|M3Tg*B~SHardI?;NOju)R#^(B`w8XV{+I7JS|Ov70-Bzvq0927{3Q8;8?%3BP7E zyimzra~Ko6XR#WTH!GKmL>RwxW6I1~{H%`Y8;|wFhR6eK zU-=JA4l(7KaY+7$7ypN)pBuUMSRdq{Zq;CZO;XZBgu~rm_d&m7&DML9*PY{MZrOBV zoA_rj2NUMhwx{!dIodpnd-AJV%_G(7%h@MaHz~~Cc6h>9{@V_YM*35p#v3hATU+_) z*UzwkX>v8kOYZS{P5yX)<5Qj$emd80{JSze`9e!X{C}ZySu(RkicfxfGl%o65BGca aIL3_W3tf1N#V-JpC4;A{pUXO@geCwT+j~a< literal 0 HcmV?d00001 diff --git a/src/Android/Resources/drawable/notification_sm.png b/src/Android/Resources/drawable/notification_sm.png new file mode 100644 index 0000000000000000000000000000000000000000..86b7c130a3e140faa970c12b0aa965104d957d1e GIT binary patch literal 364 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM3?#3wJbMaA6$SW&xB}__^aXJdjz@sDs+I)# z1v4-*ad2|;NJvU)IYmTfmXwzF^i7>Ud+D;RN6%cm{QB+3?>~S4)#y028>peh)5S4F zEfjA?$0m$~}||J8Y=r+@Q~+H2;@=jK57FnGH9xvX