2
2
using Android . Content ;
3
3
using Android . Graphics ;
4
4
using Android . Graphics . Drawables ;
5
+ using Android . Support . V4 . Content ;
5
6
using Android . Text ;
6
7
using Android . Util ;
7
8
using R = Android . Resource ;
8
9
9
10
namespace Plugin . Iconize . Droid . Controls
10
11
{
12
+ /// <summary>
13
+ /// Defines the <see cref="IconDrawable" /> drawable.
14
+ /// </summary>
15
+ /// <seealso cref="Android.Graphics.Drawables.Drawable" />
11
16
public class IconDrawable : Drawable
12
17
{
13
18
#region Constants
14
19
20
+ /// <summary>
21
+ /// The android actionbar icon size dp
22
+ /// </summary>
15
23
public const Int32 ANDROID_ACTIONBAR_ICON_SIZE_DP = 24 ;
16
24
17
25
#endregion Constants
@@ -32,12 +40,97 @@ public class IconDrawable : Drawable
32
40
33
41
#region Properties
34
42
43
+ /// <summary>
44
+ /// Return the intrinsic height of the underlying drawable object.
45
+ /// </summary>
46
+ /// <value>
47
+ /// To be added.
48
+ /// </value>
49
+ /// <remarks>
50
+ /// <para tool="javadoc-to-mdoc">Return the intrinsic height of the underlying drawable object. Returns
51
+ /// -1 if it has no intrinsic height, such as with a solid color.
52
+ /// </para>
53
+ /// <para tool="javadoc-to-mdoc">
54
+ /// <format type="text/html">
55
+ /// <a href="http://developer.android.com/reference/android/graphics/drawable/Drawable.html#getIntrinsicHeight()" target="_blank">[Android Documentation]</a>
56
+ /// </format>
57
+ /// </para>
58
+ /// </remarks>
59
+ /// <since version="Added in API level 1" />
35
60
public override Int32 IntrinsicHeight => _size ;
36
61
62
+ /// <summary>
63
+ /// Return the intrinsic width of the underlying drawable object.
64
+ /// </summary>
65
+ /// <value>
66
+ /// To be added.
67
+ /// </value>
68
+ /// <remarks>
69
+ /// <para tool="javadoc-to-mdoc">Return the intrinsic width of the underlying drawable object. Returns
70
+ /// -1 if it has no intrinsic width, such as with a solid color.
71
+ /// </para>
72
+ /// <para tool="javadoc-to-mdoc">
73
+ /// <format type="text/html">
74
+ /// <a href="http://developer.android.com/reference/android/graphics/drawable/Drawable.html#getIntrinsicWidth()" target="_blank">[Android Documentation]</a>
75
+ /// </format>
76
+ /// </para>
77
+ /// </remarks>
78
+ /// <since version="Added in API level 1" />
37
79
public override Int32 IntrinsicWidth => _size ;
38
80
81
+ /// <summary>
82
+ /// Indicates whether this view will change its appearance based on state.
83
+ /// </summary>
84
+ /// <value>
85
+ /// To be added.
86
+ /// </value>
87
+ /// <remarks>
88
+ /// <para tool="javadoc-to-mdoc">Indicates whether this view will change its appearance based on state.
89
+ /// Clients can use this to determine whether it is necessary to calculate
90
+ /// their state and call setState.</para>
91
+ /// <para tool="javadoc-to-mdoc">
92
+ /// <format type="text/html">
93
+ /// <a href="http://developer.android.com/reference/android/graphics/drawable/Drawable.html#isStateful()" target="_blank">[Android Documentation]</a>
94
+ /// </format>
95
+ /// </para>
96
+ /// </remarks>
97
+ /// <since version="Added in API level 1" />
98
+ /// <altmember cref="M:Android.Graphics.Drawables.Drawable.SetState(System.Int32[])" />
39
99
public override Boolean IsStateful => true ;
40
100
101
+ /// <summary>
102
+ /// Return the opacity/transparency of this Drawable.
103
+ /// </summary>
104
+ /// <value>
105
+ /// To be added.
106
+ /// </value>
107
+ /// <remarks>
108
+ /// <para tool="javadoc-to-mdoc">Return the opacity/transparency of this Drawable. The returned value is
109
+ /// one of the abstract format constants in
110
+ /// <c><see cref="T:Android.Graphics.PixelFormat" /></c>:
111
+ /// <c><see cref="F:Android.Graphics.Format.Unknown" /></c>,
112
+ /// <c><see cref="F:Android.Graphics.Format.Translucent" /></c>,
113
+ /// <c><see cref="F:Android.Graphics.Format.Transparent" /></c>, or
114
+ /// <c><see cref="F:Android.Graphics.Format.Opaque" /></c>.
115
+ /// </para>
116
+ /// <para tool="javadoc-to-mdoc">Generally a Drawable should be as conservative as possible with the
117
+ /// value it returns. For example, if it contains multiple child drawables
118
+ /// and only shows one of them at a time, if only one of the children is
119
+ /// TRANSLUCENT and the others are OPAQUE then TRANSLUCENT should be
120
+ /// returned. You can use the method <c><see cref="M:Android.Graphics.Drawables.Drawable.ResolveOpacity(System.Int32, System.Int32)" /></c> to perform a
121
+ /// standard reduction of two opacities to the appropriate single output.
122
+ /// </para>
123
+ /// <para tool="javadoc-to-mdoc">Note that the returned value does <i>not</i> take into account a
124
+ /// custom alpha or color filter that has been applied by the client through
125
+ /// the <c><see cref="M:Android.Graphics.Drawables.Drawable.SetAlpha(System.Int32)" /></c> or <c><see cref="M:Android.Graphics.Drawables.Drawable.SetColorFilter(Android.Graphics.ColorFilter)" /></c> methods.</para>
126
+ /// <para tool="javadoc-to-mdoc">
127
+ /// <format type="text/html">
128
+ /// <a href="http://developer.android.com/reference/android/graphics/drawable/Drawable.html#getOpacity()" target="_blank">[Android Documentation]</a>
129
+ /// </format>
130
+ /// </para>
131
+ /// </remarks>
132
+ /// <since version="Added in API level 1" />
133
+ /// <altmember cref="T:Android.Graphics.PixelFormat" />
41
134
public override Int32 Opacity => _alpha ;
42
135
43
136
#endregion Properties
@@ -157,7 +250,7 @@ public IconDrawable Color(Int32 color)
157
250
/// <returns>The current IconDrawable for chaining.</returns>
158
251
public IconDrawable ColorRes ( Int32 colorRes )
159
252
{
160
- _paint . Color = _context . Resources . GetColor ( colorRes ) ;
253
+ _paint . Color = new Color ( ContextCompat . GetColor ( _context , colorRes ) ) ;
161
254
InvalidateSelf ( ) ;
162
255
return this ;
163
256
}
0 commit comments