From a909d6934f45452fb5a6d64b6e1029bc3259346d Mon Sep 17 00:00:00 2001 From: Daniel Cazzulino Date: Fri, 22 Mar 2019 15:44:09 -0300 Subject: [PATCH] Annotate attributes with resource category hint for the IDE The code completion experience can be improved if the editor knew which string properties typically come from resources so a completion suggestion can be provided that is filtered to the type of resource the property should be pointing to (i.e. `@(string)` vs `@(drawable)`). Fixes https://github.com/xamarin/xamarin-android/issues/2862 --- .../Android.App/ActivityAttribute.cs | 5 +++++ .../Android.App/ApplicationAttribute.cs | 6 ++++++ .../Android.App/InstrumentationAttribute.cs | 3 +++ .../Android.App/ServiceAttribute.cs | 3 +++ .../Android.Content/BroadcastReceiverAttribute.cs | 3 +++ .../Android.Content/ContentProviderAttribute.cs | 3 +++ 6 files changed, 23 insertions(+) diff --git a/src/Xamarin.Android.NamingCustomAttributes/Android.App/ActivityAttribute.cs b/src/Xamarin.Android.NamingCustomAttributes/Android.App/ActivityAttribute.cs index a9550d2a70f..215be81b74d 100644 --- a/src/Xamarin.Android.NamingCustomAttributes/Android.App/ActivityAttribute.cs +++ b/src/Xamarin.Android.NamingCustomAttributes/Android.App/ActivityAttribute.cs @@ -1,4 +1,5 @@ using System; +using System.ComponentModel; using Android.Content.PM; using Android.Views; @@ -35,7 +36,9 @@ public ActivityAttribute () #if ANDROID_11 public bool HardwareAccelerated {get; set;} #endif + [Category("@drawable;@mipmap")] public string Icon {get; set;} + [Category("@string")] public string Label {get; set;} public LaunchMode LaunchMode {get; set;} #if ANDROID_17 @@ -55,6 +58,7 @@ public ActivityAttribute () public bool ResizeableActivity {get;set;} #endif #if ANDROID_25 + [Category("@drawable;@mipmap")] public string RoundIcon {get; set;} #endif #if ANDROID_24 @@ -63,6 +67,7 @@ public ActivityAttribute () public ScreenOrientation ScreenOrientation {get; set;} public bool StateNotNeeded {get; set;} public string TaskAffinity {get; set;} + [Category("@style")] public string Theme {get; set;} #if ANDROID_14 public UiOptions UiOptions {get; set;} diff --git a/src/Xamarin.Android.NamingCustomAttributes/Android.App/ApplicationAttribute.cs b/src/Xamarin.Android.NamingCustomAttributes/Android.App/ApplicationAttribute.cs index 3de483e937b..46b5e67e4c2 100644 --- a/src/Xamarin.Android.NamingCustomAttributes/Android.App/ApplicationAttribute.cs +++ b/src/Xamarin.Android.NamingCustomAttributes/Android.App/ApplicationAttribute.cs @@ -27,6 +27,7 @@ public ApplicationAttribute () public string Banner {get; set;} #endif public bool Debuggable {get; set;} + [Category("@string")] public string Description {get; set;} #if ANDROID_24 public bool DirectBootAware {get; set;} @@ -40,13 +41,16 @@ public ApplicationAttribute () public bool HardwareAccelerated {get; set;} #endif public bool HasCode {get; set;} + [Category("@drawable;@mipmap")] public string Icon {get; set;} public bool KillAfterRestore {get; set;} #if ANDROID_11 public bool LargeHeap {get; set;} #endif + [Category("@string")] public string Label {get; set;} #if ANDROID_11 + [Category("@drawable;@mipmap")] public string Logo {get; set;} #endif public Type ManageSpaceActivity {get; set;} @@ -61,12 +65,14 @@ public ApplicationAttribute () public string RestrictedAccountType {get; set;} #endif #if ANDROID_25 + [Category("@drawable;@mipmap")] public string RoundIcon {get; set;} #endif #if ANDROID_17 public bool SupportsRtl {get; set;} #endif public string TaskAffinity {get; set;} + [Category("@style")] public string Theme {get; set;} #if ANDROID_14 public UiOptions UiOptions {get; set;} diff --git a/src/Xamarin.Android.NamingCustomAttributes/Android.App/InstrumentationAttribute.cs b/src/Xamarin.Android.NamingCustomAttributes/Android.App/InstrumentationAttribute.cs index 43b50aa8248..c520c5aa59a 100644 --- a/src/Xamarin.Android.NamingCustomAttributes/Android.App/InstrumentationAttribute.cs +++ b/src/Xamarin.Android.NamingCustomAttributes/Android.App/InstrumentationAttribute.cs @@ -14,10 +14,13 @@ public InstrumentationAttribute () public bool FunctionalTest {get; set;} public bool HandleProfiling {get; set;} + [Category("@drawable;@mipmap")] public string Icon {get; set;} + [Category("@string")] public string Label {get; set;} public string Name {get; set;} #if ANDROID_25 + [Category("@drawable;@mipmap")] public string RoundIcon {get; set;} #endif public string TargetPackage {get; set;} diff --git a/src/Xamarin.Android.NamingCustomAttributes/Android.App/ServiceAttribute.cs b/src/Xamarin.Android.NamingCustomAttributes/Android.App/ServiceAttribute.cs index d3aaef17952..b57dc2e7f1d 100644 --- a/src/Xamarin.Android.NamingCustomAttributes/Android.App/ServiceAttribute.cs +++ b/src/Xamarin.Android.NamingCustomAttributes/Android.App/ServiceAttribute.cs @@ -22,14 +22,17 @@ public ServiceAttribute () #endif public bool Enabled {get; set;} public bool Exported {get; set;} + [Category("@drawable;@mipmap")] public string Icon {get; set;} #if ANDROID_16 public bool IsolatedProcess {get; set;} #endif + [Category("@string")] public string Label {get; set;} public string Permission {get; set;} public string Process {get; set;} #if ANDROID_25 + [Category("@drawable;@mipmap")] public string RoundIcon {get; set;} #endif } diff --git a/src/Xamarin.Android.NamingCustomAttributes/Android.Content/BroadcastReceiverAttribute.cs b/src/Xamarin.Android.NamingCustomAttributes/Android.Content/BroadcastReceiverAttribute.cs index b84d8c54107..cb009e6161d 100644 --- a/src/Xamarin.Android.NamingCustomAttributes/Android.Content/BroadcastReceiverAttribute.cs +++ b/src/Xamarin.Android.NamingCustomAttributes/Android.Content/BroadcastReceiverAttribute.cs @@ -15,12 +15,15 @@ public BroadcastReceiverAttribute () public bool DirectBootAware {get; set;} public bool Enabled {get; set;} public bool Exported {get; set;} + [Category("@drawable;@mipmap")] public string Icon {get; set;} + [Category("@string")] public string Label {get; set;} public string Name {get; set;} public string Permission {get; set;} public string Process {get; set;} #if ANDROID_25 + [Category("@drawable;@mipmap")] public string RoundIcon {get; set;} #endif } diff --git a/src/Xamarin.Android.NamingCustomAttributes/Android.Content/ContentProviderAttribute.cs b/src/Xamarin.Android.NamingCustomAttributes/Android.Content/ContentProviderAttribute.cs index c930ba9d11b..16a9cccbfc3 100644 --- a/src/Xamarin.Android.NamingCustomAttributes/Android.Content/ContentProviderAttribute.cs +++ b/src/Xamarin.Android.NamingCustomAttributes/Android.Content/ContentProviderAttribute.cs @@ -24,8 +24,10 @@ public ContentProviderAttribute (string[] authorities) public bool Enabled {get; set;} public bool Exported {get; set;} public bool GrantUriPermissions {get; set;} + [Category("@drawable;@mipmap")] public string Icon {get; set;} public int InitOrder {get; set;} + [Category("@string")] public string Label {get; set;} public bool MultiProcess {get; set;} public string Name {get; set;} @@ -33,6 +35,7 @@ public ContentProviderAttribute (string[] authorities) public string Process {get; set;} public string ReadPermission {get; set;} #if ANDROID_25 + [Category("@drawable;@mipmap")] public string RoundIcon {get; set;} #endif public bool Syncable {get; set;}