Skip to content
This repository has been archived by the owner on Jan 8, 2019. It is now read-only.

Commit

Permalink
- Added missing XML comments.
Browse files Browse the repository at this point in the history
- Changed GetColor to ContextCompat call.
  • Loading branch information
jsmarcus committed May 31, 2016
1 parent 25f4f5b commit 5ca12a2
Show file tree
Hide file tree
Showing 11 changed files with 515 additions and 20 deletions.
65 changes: 65 additions & 0 deletions Iconize/Plugin.Iconize.Droid/Controls/IconButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,53 @@

namespace Plugin.Iconize.Droid.Controls
{
/// <summary>
/// Defines the <see cref="IconButton" /> control.
/// </summary>
/// <seealso cref="Android.Support.V7.Widget.AppCompatButton" />
/// <seealso cref="Plugin.Iconize.Droid.IHasOnViewAttachListener" />
public class IconButton : AppCompatButton, IHasOnViewAttachListener
{
private HasOnViewAttachListenerDelegate _delegate;

/// <summary>
/// Initializes a new instance of the <see cref="IconButton"/> class.
/// </summary>
/// <param name="context">The context.</param>
public IconButton(Context context)
: base(context)
{
Init();
}

/// <summary>
/// Initializes a new instance of the <see cref="IconButton"/> class.
/// </summary>
/// <param name="context">The context.</param>
/// <param name="attrs">The attrs.</param>
public IconButton(Context context, IAttributeSet attrs)
: base(context, attrs)
{
Init();
}

/// <summary>
/// Initializes a new instance of the <see cref="IconButton"/> class.
/// </summary>
/// <param name="javaReference">The java reference.</param>
/// <param name="transfer">The transfer.</param>
public IconButton(IntPtr javaReference, JniHandleOwnership transfer)
: base(javaReference, transfer)
{
Init();
}

/// <summary>
/// Initializes a new instance of the <see cref="IconButton"/> class.
/// </summary>
/// <param name="context">The context.</param>
/// <param name="attrs">The attrs.</param>
/// <param name="defStyleAttr">The definition style attribute.</param>
public IconButton(Context context, IAttributeSet attrs, Int32 defStyleAttr)
: base(context, attrs, defStyleAttr)
{
Expand All @@ -40,24 +65,64 @@ private void Init()
TransformationMethod = null;
}

/// <summary>
/// Sets the text.
/// </summary>
/// <param name="text">The text.</param>
/// <param name="type">The type.</param>
public override void SetText(ICharSequence text, BufferType type)
{
base.SetText(this.Compute(Context, text, TextSize), type);
}

/// <summary>
/// Sets the on view attach listener.
/// </summary>
/// <param name="listener">The listener.</param>
public void SetOnViewAttachListener(IOnViewAttachListener listener)
{
if (_delegate == null)
_delegate = new HasOnViewAttachListenerDelegate(this);
_delegate.SetOnViewAttachListener(listener);
}

/// <summary>
/// This is called when the view is attached to a window.
/// </summary>
/// <remarks>
/// <para tool="javadoc-to-mdoc">This is called when the view is attached to a window. At this point it
/// has a Surface and will start drawing. Note that this function is
/// guaranteed to be called before <c><see cref="M:Android.Views.View.OnDraw(Android.Graphics.Canvas)" /></c>,
/// however it may be called any time before the first onDraw -- including
/// before or after <c><see cref="M:Android.Views.View.OnMeasure(System.Int32, System.Int32)" /></c>.</para>
/// <para tool="javadoc-to-mdoc">
/// <format type="text/html">
/// <a href="http://developer.android.com/reference/android/view/View.html#onAttachedToWindow()" target="_blank">[Android Documentation]</a>
/// </format>
/// </para>
/// </remarks>
/// <since version="Added in API level 1" />
/// <altmember cref="M:Android.Views.View.OnDetachedFromWindow" />
protected override void OnAttachedToWindow()
{
base.OnAttachedToWindow();
_delegate.OnAttachedToWindow();
}

/// <summary>
/// This is called when the view is detached from a window.
/// </summary>
/// <remarks>
/// <para tool="javadoc-to-mdoc">This is called when the view is detached from a window. At this point it
/// no longer has a surface for drawing.</para>
/// <para tool="javadoc-to-mdoc">
/// <format type="text/html">
/// <a href="http://developer.android.com/reference/android/view/View.html#onDetachedFromWindow()" target="_blank">[Android Documentation]</a>
/// </format>
/// </para>
/// </remarks>
/// <since version="Added in API level 1" />
/// <altmember cref="M:Android.Views.View.OnAttachedToWindow" />
protected override void OnDetachedFromWindow()
{
base.OnDetachedFromWindow();
Expand Down
95 changes: 94 additions & 1 deletion Iconize/Plugin.Iconize.Droid/Controls/IconDrawable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,24 @@
using Android.Content;
using Android.Graphics;
using Android.Graphics.Drawables;
using Android.Support.V4.Content;
using Android.Text;
using Android.Util;
using R = Android.Resource;

namespace Plugin.Iconize.Droid.Controls
{
/// <summary>
/// Defines the <see cref="IconDrawable" /> drawable.
/// </summary>
/// <seealso cref="Android.Graphics.Drawables.Drawable" />
public class IconDrawable : Drawable
{
#region Constants

/// <summary>
/// The android actionbar icon size dp
/// </summary>
public const Int32 ANDROID_ACTIONBAR_ICON_SIZE_DP = 24;

#endregion Constants
Expand All @@ -32,12 +40,97 @@ public class IconDrawable : Drawable

#region Properties

/// <summary>
/// Return the intrinsic height of the underlying drawable object.
/// </summary>
/// <value>
/// To be added.
/// </value>
/// <remarks>
/// <para tool="javadoc-to-mdoc">Return the intrinsic height of the underlying drawable object. Returns
/// -1 if it has no intrinsic height, such as with a solid color.
/// </para>
/// <para tool="javadoc-to-mdoc">
/// <format type="text/html">
/// <a href="http://developer.android.com/reference/android/graphics/drawable/Drawable.html#getIntrinsicHeight()" target="_blank">[Android Documentation]</a>
/// </format>
/// </para>
/// </remarks>
/// <since version="Added in API level 1" />
public override Int32 IntrinsicHeight => _size;

/// <summary>
/// Return the intrinsic width of the underlying drawable object.
/// </summary>
/// <value>
/// To be added.
/// </value>
/// <remarks>
/// <para tool="javadoc-to-mdoc">Return the intrinsic width of the underlying drawable object. Returns
/// -1 if it has no intrinsic width, such as with a solid color.
/// </para>
/// <para tool="javadoc-to-mdoc">
/// <format type="text/html">
/// <a href="http://developer.android.com/reference/android/graphics/drawable/Drawable.html#getIntrinsicWidth()" target="_blank">[Android Documentation]</a>
/// </format>
/// </para>
/// </remarks>
/// <since version="Added in API level 1" />
public override Int32 IntrinsicWidth => _size;

/// <summary>
/// Indicates whether this view will change its appearance based on state.
/// </summary>
/// <value>
/// To be added.
/// </value>
/// <remarks>
/// <para tool="javadoc-to-mdoc">Indicates whether this view will change its appearance based on state.
/// Clients can use this to determine whether it is necessary to calculate
/// their state and call setState.</para>
/// <para tool="javadoc-to-mdoc">
/// <format type="text/html">
/// <a href="http://developer.android.com/reference/android/graphics/drawable/Drawable.html#isStateful()" target="_blank">[Android Documentation]</a>
/// </format>
/// </para>
/// </remarks>
/// <since version="Added in API level 1" />
/// <altmember cref="M:Android.Graphics.Drawables.Drawable.SetState(System.Int32[])" />
public override Boolean IsStateful => true;

/// <summary>
/// Return the opacity/transparency of this Drawable.
/// </summary>
/// <value>
/// To be added.
/// </value>
/// <remarks>
/// <para tool="javadoc-to-mdoc">Return the opacity/transparency of this Drawable. The returned value is
/// one of the abstract format constants in
/// <c><see cref="T:Android.Graphics.PixelFormat" /></c>:
/// <c><see cref="F:Android.Graphics.Format.Unknown" /></c>,
/// <c><see cref="F:Android.Graphics.Format.Translucent" /></c>,
/// <c><see cref="F:Android.Graphics.Format.Transparent" /></c>, or
/// <c><see cref="F:Android.Graphics.Format.Opaque" /></c>.
/// </para>
/// <para tool="javadoc-to-mdoc">Generally a Drawable should be as conservative as possible with the
/// value it returns. For example, if it contains multiple child drawables
/// and only shows one of them at a time, if only one of the children is
/// TRANSLUCENT and the others are OPAQUE then TRANSLUCENT should be
/// returned. You can use the method <c><see cref="M:Android.Graphics.Drawables.Drawable.ResolveOpacity(System.Int32, System.Int32)" /></c> to perform a
/// standard reduction of two opacities to the appropriate single output.
/// </para>
/// <para tool="javadoc-to-mdoc">Note that the returned value does <i>not</i> take into account a
/// custom alpha or color filter that has been applied by the client through
/// 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>
/// <para tool="javadoc-to-mdoc">
/// <format type="text/html">
/// <a href="http://developer.android.com/reference/android/graphics/drawable/Drawable.html#getOpacity()" target="_blank">[Android Documentation]</a>
/// </format>
/// </para>
/// </remarks>
/// <since version="Added in API level 1" />
/// <altmember cref="T:Android.Graphics.PixelFormat" />
public override Int32 Opacity => _alpha;

#endregion Properties
Expand Down Expand Up @@ -157,7 +250,7 @@ public IconDrawable Color(Int32 color)
/// <returns>The current IconDrawable for chaining.</returns>
public IconDrawable ColorRes(Int32 colorRes)
{
_paint.Color = _context.Resources.GetColor(colorRes);
_paint.Color = new Color(ContextCompat.GetColor(_context, colorRes));
InvalidateSelf();
return this;
}
Expand Down
65 changes: 65 additions & 0 deletions Iconize/Plugin.Iconize.Droid/Controls/IconTextView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,53 @@

namespace Plugin.Iconize.Droid.Controls
{
/// <summary>
/// Defines the <see cref="IconTextView" /> control.
/// </summary>
/// <seealso cref="Android.Widget.TextView" />
/// <seealso cref="Plugin.Iconize.Droid.IHasOnViewAttachListener" />
public class IconTextView : TextView, IHasOnViewAttachListener
{
private HasOnViewAttachListenerDelegate _delegate;

/// <summary>
/// Initializes a new instance of the <see cref="IconTextView"/> class.
/// </summary>
/// <param name="context">The context.</param>
public IconTextView(Context context)
: base(context)
{
Init();
}

/// <summary>
/// Initializes a new instance of the <see cref="IconTextView"/> class.
/// </summary>
/// <param name="context">The context.</param>
/// <param name="attrs">The attrs.</param>
public IconTextView(Context context, IAttributeSet attrs)
: base(context, attrs)
{
Init();
}

/// <summary>
/// Initializes a new instance of the <see cref="IconTextView"/> class.
/// </summary>
/// <param name="javaReference">The java reference.</param>
/// <param name="transfer">The transfer.</param>
public IconTextView(IntPtr javaReference, JniHandleOwnership transfer)
: base(javaReference, transfer)
{
Init();
}

/// <summary>
/// Initializes a new instance of the <see cref="IconTextView"/> class.
/// </summary>
/// <param name="context">The context.</param>
/// <param name="attrs">The attrs.</param>
/// <param name="defStyleAttr">The definition style attribute.</param>
public IconTextView(Context context, IAttributeSet attrs, Int32 defStyleAttr)
: base(context, attrs, defStyleAttr)
{
Expand All @@ -40,24 +65,64 @@ private void Init()
TransformationMethod = null;
}

/// <summary>
/// Sets the text.
/// </summary>
/// <param name="text">The text.</param>
/// <param name="type">The type.</param>
public override void SetText(ICharSequence text, BufferType type)
{
base.SetText(this.Compute(Context, text, TextSize), type);
}

/// <summary>
/// Sets the on view attach listener.
/// </summary>
/// <param name="listener">The listener.</param>
public void SetOnViewAttachListener(IOnViewAttachListener listener)
{
if (_delegate == null)
_delegate = new HasOnViewAttachListenerDelegate(this);
_delegate.SetOnViewAttachListener(listener);
}

/// <summary>
/// This is called when the view is attached to a window.
/// </summary>
/// <remarks>
/// <para tool="javadoc-to-mdoc">This is called when the view is attached to a window. At this point it
/// has a Surface and will start drawing. Note that this function is
/// guaranteed to be called before <c><see cref="M:Android.Views.View.OnDraw(Android.Graphics.Canvas)" /></c>,
/// however it may be called any time before the first onDraw -- including
/// before or after <c><see cref="M:Android.Views.View.OnMeasure(System.Int32, System.Int32)" /></c>.</para>
/// <para tool="javadoc-to-mdoc">
/// <format type="text/html">
/// <a href="http://developer.android.com/reference/android/view/View.html#onAttachedToWindow()" target="_blank">[Android Documentation]</a>
/// </format>
/// </para>
/// </remarks>
/// <since version="Added in API level 1" />
/// <altmember cref="M:Android.Views.View.OnDetachedFromWindow" />
protected override void OnAttachedToWindow()
{
base.OnAttachedToWindow();
_delegate.OnAttachedToWindow();
}

/// <summary>
/// This is called when the view is detached from a window.
/// </summary>
/// <remarks>
/// <para tool="javadoc-to-mdoc">This is called when the view is detached from a window. At this point it
/// no longer has a surface for drawing.</para>
/// <para tool="javadoc-to-mdoc">
/// <format type="text/html">
/// <a href="http://developer.android.com/reference/android/view/View.html#onDetachedFromWindow()" target="_blank">[Android Documentation]</a>
/// </format>
/// </para>
/// </remarks>
/// <since version="Added in API level 1" />
/// <altmember cref="M:Android.Views.View.OnAttachedToWindow" />
protected override void OnDetachedFromWindow()
{
base.OnDetachedFromWindow();
Expand Down
Loading

0 comments on commit 5ca12a2

Please sign in to comment.