Example #1
0
        public override void inflate(android.content.res.Resources r, org.xmlpull.v1.XmlPullParser
                                     parser, android.util.AttributeSet attrs)
        {
            base.inflate(r, parser, attrs);
            int type;
            int low        = 0;
            int innerDepth = parser.getDepth() + 1;
            int depth;

            while ((type = parser.next()) != org.xmlpull.v1.XmlPullParserClass.END_DOCUMENT &&
                   ((depth = parser.getDepth()) >= innerDepth || type != org.xmlpull.v1.XmlPullParserClass.END_TAG
                   ))
            {
                if (type != org.xmlpull.v1.XmlPullParserClass.START_TAG)
                {
                    continue;
                }
                if (depth > innerDepth || !parser.getName().Equals("item"))
                {
                    continue;
                }
                android.content.res.TypedArray a = r.obtainAttributes(attrs, [email protected].
                                                                      styleable.LevelListDrawableItem);
                low = a.getInt([email protected]_minLevel, 0);
                int high = a.getInt([email protected]_maxLevel,
                                    0);
                int drawableRes = a.getResourceId([email protected]_drawable
                                                  , 0);
                a.recycle();
                if (high < 0)
                {
                    throw new org.xmlpull.v1.XmlPullParserException(parser.getPositionDescription() +
                                                                    ": <item> tag requires a 'maxLevel' attribute");
                }
                android.graphics.drawable.Drawable dr;
                if (drawableRes != 0)
                {
                    dr = r.getDrawable(drawableRes);
                }
                else
                {
                    while ((type = parser.next()) == org.xmlpull.v1.XmlPullParserClass.TEXT)
                    {
                    }
                    if (type != org.xmlpull.v1.XmlPullParserClass.START_TAG)
                    {
                        throw new org.xmlpull.v1.XmlPullParserException(parser.getPositionDescription() +
                                                                        ": <item> tag requires a 'drawable' attribute or " + "child tag defining a drawable"
                                                                        );
                    }
                    dr = android.graphics.drawable.Drawable.createFromXmlInner(r, parser, attrs);
                }
                mLevelListState.addLevel(low, high, dr);
            }
            onLevelChange(getLevel());
        }
Example #2
0
        /// <summary>
        /// Construct a new spinner with the given context's theme, the supplied attribute set,
        /// and default style.
        /// </summary>
        /// <remarks>
        /// Construct a new spinner with the given context's theme, the supplied attribute set,
        /// and default style. <code>mode</code> may be one of
        /// <see cref="MODE_DIALOG">MODE_DIALOG</see>
        /// or
        /// <see cref="MODE_DROPDOWN">MODE_DROPDOWN</see>
        /// and determines how the user will select choices from the spinner.
        /// </remarks>
        /// <param name="context">
        /// The Context the view is running in, through which it can
        /// access the current theme, resources, etc.
        /// </param>
        /// <param name="attrs">The attributes of the XML tag that is inflating the view.</param>
        /// <param name="defStyle">
        /// The default style to apply to this view. If 0, no style
        /// will be applied (beyond what is included in the theme). This may
        /// either be an attribute resource, whose value will be retrieved
        /// from the current theme, or an explicit style resource.
        /// </param>
        /// <param name="mode">Constant describing how the user will select choices from the spinner.
        ///     </param>
        /// <seealso cref="MODE_DIALOG">MODE_DIALOG</seealso>
        /// <seealso cref="MODE_DROPDOWN">MODE_DROPDOWN</seealso>
        public Spinner(android.content.Context context, android.util.AttributeSet attrs,
                       int defStyle, int mode) : base(context, attrs, defStyle)
        {
            // Only measure this many items to get a decent max width.
            android.content.res.TypedArray a = context.obtainStyledAttributes(attrs, [email protected]
                                                                              .styleable.Spinner, defStyle, 0);
            if (mode == MODE_THEME)
            {
                mode = a.getInt([email protected]_spinnerMode, MODE_DIALOG);
            }
            switch (mode)
            {
            case MODE_DIALOG:
            {
                mPopup = new android.widget.Spinner.DialogPopup(this);
                break;
            }

            case MODE_DROPDOWN:
            {
                android.widget.Spinner.DropdownPopup popup = new android.widget.Spinner.DropdownPopup
                                                                 (this, context, attrs, defStyle);
                mDropDownWidth = a.getLayoutDimension([email protected]_dropDownWidth
                                                      , android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
                popup.setBackgroundDrawable(a.getDrawable([email protected]_popupBackground
                                                          ));
                int verticalOffset = a.getDimensionPixelOffset([email protected]_dropDownVerticalOffset
                                                               , 0);
                if (verticalOffset != 0)
                {
                    popup.setVerticalOffset(verticalOffset);
                }
                int horizontalOffset = a.getDimensionPixelOffset([email protected]_dropDownHorizontalOffset
                                                                 , 0);
                if (horizontalOffset != 0)
                {
                    popup.setHorizontalOffset(horizontalOffset);
                }
                mPopup = popup;
                break;
            }
            }
            mGravity = a.getInt([email protected]_gravity, android.view.Gravity
                                .CENTER);
            mPopup.setPromptText(java.lang.CharSequenceProxy.Wrap(a.getString([email protected]
                                                                              .styleable.Spinner_prompt)));
            a.recycle();
            // Base constructor can call setAdapter before we initialize mPopup.
            // Finish setting things up if this happened.
            if (mTempAdapter != null)
            {
                mPopup.setAdapter(mTempAdapter);
                mTempAdapter = null;
            }
        }
Example #3
0
 /// <summary>Instantiates the IconMenuView that is linked with the provided MenuBuilder.
 ///     </summary>
 /// <remarks>Instantiates the IconMenuView that is linked with the provided MenuBuilder.
 ///     </remarks>
 public IconMenuView(android.content.Context context, android.util.AttributeSet attrs
                     ) : base(context, attrs)
 {
     android.content.res.TypedArray a = context.obtainStyledAttributes(attrs, [email protected]
                                                                       .styleable.IconMenuView, 0, 0);
     mRowHeight = a.getDimensionPixelSize([email protected]_rowHeight
                                          , 64);
     mMaxRows        = a.getInt([email protected]_maxRows, 2);
     mMaxItems       = a.getInt([email protected]_maxItems, 6);
     mMaxItemsPerRow = a.getInt([email protected]_maxItemsPerRow
                                , 3);
     mMoreIcon = a.getDrawable([email protected]_moreIcon);
     a.recycle();
     a = context.obtainStyledAttributes(attrs, [email protected],
                                        0, 0);
     mItemBackground = a.getDrawable([email protected]_itemBackground
                                     );
     mHorizontalDivider = a.getDrawable([email protected]_horizontalDivider
                                        );
     mHorizontalDividerRects = new java.util.ArrayList <android.graphics.Rect>();
     mVerticalDivider        = a.getDrawable([email protected]_verticalDivider
                                             );
     mVerticalDividerRects = new java.util.ArrayList <android.graphics.Rect>();
     mAnimations           = a.getResourceId([email protected]_windowAnimationStyle
                                             , 0);
     a.recycle();
     if (mHorizontalDivider != null)
     {
         mHorizontalDividerHeight = mHorizontalDivider.getIntrinsicHeight();
         // Make sure to have some height for the divider
         if (mHorizontalDividerHeight == -1)
         {
             mHorizontalDividerHeight = 1;
         }
     }
     if (mVerticalDivider != null)
     {
         mVerticalDividerWidth = mVerticalDivider.getIntrinsicWidth();
         // Make sure to have some width for the divider
         if (mVerticalDividerWidth == -1)
         {
             mVerticalDividerWidth = 1;
         }
     }
     mLayout = new int[mMaxRows];
     // This view will be drawing the dividers
     setWillNotDraw(false);
     // This is so we'll receive the MENU key in touch mode
     setFocusableInTouchMode(true);
     // This is so our children can still be arrow-key focused
     setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
 }
Example #4
0
 /// <summary><inheritDoc></inheritDoc></summary>
 public LayoutParams(android.content.Context c, android.util.AttributeSet attrs) :
     base(c, attrs)
 {
     android.content.res.TypedArray a = c.obtainStyledAttributes(attrs, [email protected]
                                                                 .styleable.TableRow_Cell);
     column = a.getInt([email protected]_Cell_layout_column, -1);
     span   = a.getInt([email protected]_Cell_layout_span, 1);
     if (span <= 1)
     {
         span = 1;
     }
     a.recycle();
 }
Example #5
0
        public RatingBar(android.content.Context context, android.util.AttributeSet attrs
                         , int defStyle) : base(context, attrs, defStyle)
        {
            android.content.res.TypedArray a = context.obtainStyledAttributes(attrs, [email protected]
                                                                              .styleable.RatingBar, defStyle, 0);
            int numStars = a.getInt([email protected]_numStars, mNumStars
                                    );

            setIsIndicator(a.getBoolean([email protected]_isIndicator,
                                        !mIsUserSeekable));
            float rating   = a.getFloat([email protected]_rating, -1);
            float stepSize = a.getFloat([email protected]_stepSize, -1);

            a.recycle();
            if (numStars > 0 && numStars != mNumStars)
            {
                setNumStars(numStars);
            }
            if (stepSize >= 0)
            {
                setStepSize(stepSize);
            }
            else
            {
                setStepSize(0.5f);
            }
            if (rating >= 0)
            {
                setRating(rating);
            }
            // A touch inside a star fill up to that fractional area (slightly more
            // than 1 so boundaries round up).
            mTouchProgressOffset = 1.1f;
        }
        /// <summary>Creates a new layout animation controller from external resources.</summary>
        /// <remarks>Creates a new layout animation controller from external resources.</remarks>
        /// <param name="context">
        /// the Context the view  group is running in, through which
        /// it can access the resources
        /// </param>
        /// <param name="attrs">
        /// the attributes of the XML tag that is inflating the
        /// layout animation controller
        /// </param>
        public LayoutAnimationController(android.content.Context context, android.util.AttributeSet
                                         attrs)
        {
            android.content.res.TypedArray a = context.obtainStyledAttributes(attrs, [email protected]
                                                                              .styleable.LayoutAnimation);
            android.view.animation.Animation.Description d = android.view.animation.Animation
                                                             .Description.parseValue(a.peekValue([email protected]_delay
                                                                                                 ));
            mDelay = d.value;
            mOrder = a.getInt([email protected]_animationOrder, ORDER_NORMAL
                              );
            int resource = a.getResourceId([email protected]_animation
                                           , 0);

            if (resource > 0)
            {
                setAnimation(context, resource);
            }
            resource = a.getResourceId([email protected]_interpolator
                                       , 0);
            if (resource > 0)
            {
                setInterpolator(context, resource);
            }
            a.recycle();
        }
Example #7
0
        /// <summary>
        /// This method returns the given drawable with a number on it. The number drawable will be on
        /// the top left of base drawable and its size with respect to the base drawable shall be set in
        /// theme attributes R.attr.numberIconWidthAsPercentOfAppIcon and
        /// R.attr.numberIconHeightAsPercentOfAppIcon (default is 50%)
        /// </summary>
        /// <param name="baseDrawable">
        ///            Drawable to which number will be added </param>
        /// <param name="number">
        ///            An integer which will be expressed by the drawable </param>
        /// <param name="context">
        ///            The base context </param>
        /// <returns> Drawable with number </returns>
        public static Drawable getDefaultDrawableWithNumber(Drawable baseDrawable, int number, Context context)
        {
            int[] percentArray = new int[] { R.attr.numberIconWidthAsPercentOfAppIcon, R.attr.numberIconHeightAsPercentOfAppIcon };

            TypedArray array = context.obtainStyledAttributes(percentArray);

            array.getInt(0, 50);

            float appIconWidthRatio  = (float)array.getInt(0, DEFFAULT_PROPORTION_TO_ICON) / 100f;
            float appIconHeightRatio = (float)array.getInt(1, DEFFAULT_PROPORTION_TO_ICON) / 100f;

            int shiftFromLeft   = (int)((1.0f - appIconWidthRatio) * baseDrawable.IntrinsicWidth);
            int shiftFromBottom = (int)((1.0f - appIconHeightRatio) * baseDrawable.IntrinsicHeight);

            array.recycle();

            return(getDrawableWithNumber(baseDrawable, number, shiftFromLeft, shiftFromBottom, context));
        }
Example #8
0
 /// <summary><inheritDoc></inheritDoc></summary>
 public LayoutParams(android.content.Context c, android.util.AttributeSet attrs) :
     base(c, attrs)
 {
     android.content.res.TypedArray a = c.obtainStyledAttributes(attrs, [email protected]
                                                                 .styleable.FrameLayout_Layout);
     gravity = a.getInt([email protected]_Layout_layout_gravity
                        , -1);
     a.recycle();
 }
Example #9
0
        public ImageView(android.content.Context context, android.util.AttributeSet attrs
                         , int defStyle) : base(context, attrs, defStyle)
        {
            initImageView();
            android.content.res.TypedArray a = context.obtainStyledAttributes(attrs, [email protected]
                                                                              .styleable.ImageView, defStyle, 0);
            android.graphics.drawable.Drawable d = a.getDrawable([email protected]
                                                                 .ImageView_src);
            if (d != null)
            {
                setImageDrawable(d);
            }
            mBaselineAlignBottom = a.getBoolean([email protected]_baselineAlignBottom
                                                , false);
            mBaseline = a.getDimensionPixelSize([email protected]_baseline
                                                , -1);
            setAdjustViewBounds(a.getBoolean([email protected]_adjustViewBounds
                                             , false));
            setMaxWidth(a.getDimensionPixelSize([email protected]_maxWidth
                                                , int.MaxValue));
            setMaxHeight(a.getDimensionPixelSize([email protected]_maxHeight
                                                 , int.MaxValue));
            int index = a.getInt([email protected]_scaleType, -1);

            if (index >= 0)
            {
                setScaleType(sScaleTypeArray[index]);
            }
            int tint = a.getInt([email protected]_tint, 0);

            if (tint != 0)
            {
                setColorFilter(tint);
            }
            int alpha = a.getInt([email protected]_drawableAlpha, 255);

            if (alpha != 255)
            {
                setAlpha(alpha);
            }
            mCropToPadding = a.getBoolean([email protected]_cropToPadding
                                          , false);
            a.recycle();
        }
 /// <summary>Creates a new grid layout animation controller from external resources.</summary>
 /// <remarks>Creates a new grid layout animation controller from external resources.</remarks>
 /// <param name="context">
 /// the Context the view  group is running in, through which
 /// it can access the resources
 /// </param>
 /// <param name="attrs">
 /// the attributes of the XML tag that is inflating the
 /// layout animation controller
 /// </param>
 public GridLayoutAnimationController(android.content.Context context, android.util.AttributeSet
                                      attrs) : base(context, attrs)
 {
     android.content.res.TypedArray a = context.obtainStyledAttributes(attrs, [email protected]
                                                                       .styleable.GridLayoutAnimation);
     android.view.animation.Animation.Description d = android.view.animation.Animation
                                                      .Description.parseValue(a.peekValue([email protected]_columnDelay
                                                                                          ));
     mColumnDelay = d.value;
     d            = android.view.animation.Animation.Description.parseValue(a.peekValue([email protected]
                                                                                        .styleable.GridLayoutAnimation_rowDelay));
     mRowDelay = d.value;
     //noinspection PointlessBitwiseExpression
     mDirection = a.getInt([email protected]_direction
                           , DIRECTION_LEFT_TO_RIGHT | DIRECTION_TOP_TO_BOTTOM);
     mDirectionPriority = a.getInt([email protected]_directionPriority
                                   , PRIORITY_NONE);
     a.recycle();
 }
Example #11
0
        /// <summary>
        /// Sets the switch text color, size, style, hint color, and highlight color
        /// from the specified TextAppearance resource.
        /// </summary>
        /// <remarks>
        /// Sets the switch text color, size, style, hint color, and highlight color
        /// from the specified TextAppearance resource.
        /// </remarks>
        public virtual void setSwitchTextAppearance(android.content.Context context, int
                                                    resid)
        {
            android.content.res.TypedArray appearance = context.obtainStyledAttributes(resid,
                                                                                       [email protected]);
            android.content.res.ColorStateList colors;
            int ts;

            colors = appearance.getColorStateList([email protected]_textColor
                                                  );
            if (colors != null)
            {
                mTextColors = colors;
            }
            else
            {
                // If no color set in TextAppearance, default to the view's textColor
                mTextColors = getTextColors();
            }
            ts = appearance.getDimensionPixelSize([email protected]_textSize
                                                  , 0);
            if (ts != 0)
            {
                if (ts != mTextPaint.getTextSize())
                {
                    mTextPaint.setTextSize(ts);
                    requestLayout();
                }
            }
            int typefaceIndex;
            int styleIndex;

            typefaceIndex = appearance.getInt([email protected]_typeface
                                              , -1);
            styleIndex = appearance.getInt([email protected]_textStyle
                                           , -1);
            setSwitchTypefaceByIndex(typefaceIndex, styleIndex);
            appearance.recycle();
        }
Example #12
0
 public ViewFlipper(android.content.Context context, android.util.AttributeSet attrs
                    ) : base(context, attrs)
 {
     mReceiver = new _BroadcastReceiver_69(this);
     mHandler  = new _Handler_201(this);
     android.content.res.TypedArray a = context.obtainStyledAttributes(attrs, [email protected]
                                                                       .styleable.ViewFlipper);
     mFlipInterval = a.getInt([email protected]_flipInterval,
                              DEFAULT_INTERVAL);
     mAutoStart = a.getBoolean([email protected]_autoStart, false
                               );
     a.recycle();
 }
Example #13
0
        public override void inflate(android.content.res.Resources r, org.xmlpull.v1.XmlPullParser
                                     parser, android.util.AttributeSet attrs)
        {
            base.inflate(r, parser, attrs);
            int type;

            android.content.res.TypedArray a = r.obtainAttributes(attrs, [email protected].
                                                                  styleable.ClipDrawable);
            int orientation = a.getInt([email protected]_clipOrientation
                                       , HORIZONTAL);
            int g = a.getInt([email protected]_gravity, android.view.Gravity
                             .LEFT);

            android.graphics.drawable.Drawable dr = a.getDrawable([email protected]
                                                                  .ClipDrawable_drawable);
            a.recycle();
            int outerDepth = parser.getDepth();

            while ((type = parser.next()) != org.xmlpull.v1.XmlPullParserClass.END_DOCUMENT &&
                   (type != org.xmlpull.v1.XmlPullParserClass.END_TAG || parser.getDepth() > outerDepth
                   ))
            {
                if (type != org.xmlpull.v1.XmlPullParserClass.START_TAG)
                {
                    continue;
                }
                dr = android.graphics.drawable.Drawable.createFromXmlInner(r, parser, attrs);
            }
            if (dr == null)
            {
                throw new System.ArgumentException("No drawable specified for <clip>");
            }
            mClipState.mDrawable    = dr;
            mClipState.mOrientation = orientation;
            mClipState.mGravity     = g;
            dr.setCallback(this);
        }
Example #14
0
 public AdapterViewFlipper(android.content.Context context, android.util.AttributeSet
                           attrs) : base(context, attrs)
 {
     mReceiver = new _BroadcastReceiver_77(this);
     mHandler  = new _Handler_249(this);
     android.content.res.TypedArray a = context.obtainStyledAttributes(attrs, [email protected]
                                                                       .styleable.AdapterViewFlipper);
     mFlipInterval = a.getInt([email protected]_flipInterval
                              , DEFAULT_INTERVAL);
     mAutoStart = a.getBoolean([email protected]_autoStart
                               , false);
     // A view flipper should cycle through the views
     mLoopViews = true;
     a.recycle();
 }
Example #15
0
        public override void inflate(android.content.res.Resources r, org.xmlpull.v1.XmlPullParser
                                     parser, android.util.AttributeSet attrs)
        {
            base.inflate(r, parser, attrs);
            int type;

            android.content.res.TypedArray a = r.obtainAttributes(attrs, [email protected].
                                                                  styleable.ScaleDrawable);
            float sw = getPercent(a, [email protected]_scaleWidth);
            float sh = getPercent(a, [email protected]_scaleHeight);
            int   g  = a.getInt([email protected]_scaleGravity, android.view.Gravity
                                .LEFT);
            bool min = a.getBoolean([email protected]_useIntrinsicSizeAsMinimum
                                    , false);

            android.graphics.drawable.Drawable dr = a.getDrawable([email protected]
                                                                  .ScaleDrawable_drawable);
            a.recycle();
            int outerDepth = parser.getDepth();

            while ((type = parser.next()) != org.xmlpull.v1.XmlPullParserClass.END_DOCUMENT &&
                   (type != org.xmlpull.v1.XmlPullParserClass.END_TAG || parser.getDepth() > outerDepth
                   ))
            {
                if (type != org.xmlpull.v1.XmlPullParserClass.START_TAG)
                {
                    continue;
                }
                dr = android.graphics.drawable.Drawable.createFromXmlInner(r, parser, attrs);
            }
            if (dr == null)
            {
                throw new System.ArgumentException("No drawable specified for <scale>");
            }
            mScaleState.mDrawable              = dr;
            mScaleState.mScaleWidth            = sw;
            mScaleState.mScaleHeight           = sh;
            mScaleState.mGravity               = g;
            mScaleState.mUseIntrinsicSizeAsMin = min;
            if (dr != null)
            {
                dr.setCallback(this);
            }
        }
Example #16
0
 /// <summary>Create a new instance.</summary>
 /// <remarks>Create a new instance.</remarks>
 /// <param name="context">The application environment.</param>
 /// <param name="attrs">A collection of attributes.</param>
 /// <param name="defStyle">The default style to apply to this view.</param>
 public ActivityChooserView(android.content.Context context, android.util.AttributeSet
                            attrs, int defStyle) : base(context, attrs, defStyle)
 {
     mModelDataSetOberver    = new _DataSetObserver_118(this);
     mOnGlobalLayoutListener = new _OnGlobalLayoutListener_132(this);
     android.content.res.TypedArray attributesArray = context.obtainStyledAttributes(attrs
                                                                                     , [email protected], defStyle, 0);
     mInitialActivityCount = attributesArray.getInt([email protected]_initialActivityCount
                                                    , android.widget.ActivityChooserView.ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_DEFAULT
                                                    );
     android.graphics.drawable.Drawable expandActivityOverflowButtonDrawable = attributesArray
                                                                               .getDrawable([email protected]_expandActivityOverflowButtonDrawable
                                                                                            );
     attributesArray.recycle();
     android.view.LayoutInflater inflater = android.view.LayoutInflater.from(mContext);
     inflater.inflate([email protected]_chooser_view, this, true);
     mCallbacks = new android.widget.ActivityChooserView.Callbacks(this);
     mActivityChooserContent = (android.widget.LinearLayout)findViewById([email protected]
                                                                         .id.activity_chooser_view_content);
     mActivityChooserContentBackground = mActivityChooserContent.getBackground();
     mDefaultActivityButton            = (android.widget.FrameLayout)findViewById([email protected]
                                                                                  .id.default_activity_button);
     mDefaultActivityButton.setOnClickListener(mCallbacks);
     mDefaultActivityButton.setOnLongClickListener(mCallbacks);
     mDefaultActivityButtonImage = (android.widget.ImageView)mDefaultActivityButton.findViewById
                                       ([email protected]);
     mExpandActivityOverflowButton = (android.widget.FrameLayout)findViewById([email protected]
                                                                              .id.expand_activities_button);
     mExpandActivityOverflowButton.setOnClickListener(mCallbacks);
     mExpandActivityOverflowButtonImage = (android.widget.ImageView)mExpandActivityOverflowButton
                                          .findViewById([email protected]);
     mExpandActivityOverflowButtonImage.setImageDrawable(expandActivityOverflowButtonDrawable
                                                         );
     mAdapter = new android.widget.ActivityChooserView.ActivityChooserViewAdapter(this
                                                                                  );
     mAdapter.registerDataSetObserver(new _DataSetObserver_239(this));
     android.content.res.Resources resources = context.getResources();
     mListPopupMaxWidth = System.Math.Max(resources.getDisplayMetrics().widthPixels /
                                          2, resources.getDimensionPixelSize([email protected]_prefDialogWidth
                                                                             ));
 }
Example #17
0
 public FrameLayout(android.content.Context context, android.util.AttributeSet attrs
                    , int defStyle) : base(context, attrs, defStyle)
 {
     android.content.res.TypedArray a = context.obtainStyledAttributes(attrs, [email protected]
                                                                       .styleable.FrameLayout, defStyle, 0);
     mForegroundGravity = a.getInt([email protected]_foregroundGravity
                                   , mForegroundGravity);
     android.graphics.drawable.Drawable d = a.getDrawable([email protected]
                                                          .FrameLayout_foreground);
     if (d != null)
     {
         setForeground(d);
     }
     if (a.getBoolean([email protected]_measureAllChildren, false
                      ))
     {
         setMeasureAllChildren(true);
     }
     mForegroundInPadding = a.getBoolean([email protected]_foregroundInsidePadding
                                         , true);
     a.recycle();
 }
Example #18
0
        private void init(android.content.Context context)
        {
            // Get both the scrollbar states drawables
            android.content.res.TypedArray ta = context.getTheme().obtainStyledAttributes(ATTRS
                                                                                          );
            useThumbDrawable(context, ta.getDrawable(THUMB_DRAWABLE));
            mTrackDrawable        = ta.getDrawable(TRACK_DRAWABLE);
            mOverlayDrawableLeft  = ta.getDrawable(PREVIEW_BACKGROUND_LEFT);
            mOverlayDrawableRight = ta.getDrawable(PREVIEW_BACKGROUND_RIGHT);
            mOverlayPosition      = ta.getInt(OVERLAY_POSITION, OVERLAY_FLOATING);
            mScrollCompleted      = true;
            getSectionsFromIndexer();
            mOverlaySize = context.getResources().getDimensionPixelSize([email protected]
                                                                        .fastscroll_overlay_size);
            mOverlayPos = new android.graphics.RectF();
            mScrollFade = new android.widget.FastScroller.ScrollFade(this);
            mPaint      = new android.graphics.Paint();
            mPaint.setAntiAlias(true);
            mPaint.setTextAlign(android.graphics.Paint.Align.CENTER);
            mPaint.setTextSize(mOverlaySize / 2);
            android.content.res.ColorStateList textColor = ta.getColorStateList(TEXT_COLOR);
            int textColorNormal = textColor.getDefaultColor();

            mPaint.setColor(textColorNormal);
            mPaint.setStyle(android.graphics.Paint.Style.FILL_AND_STROKE);
            // to show mOverlayDrawable properly
            if (mList.getWidth() > 0 && mList.getHeight() > 0)
            {
                onSizeChanged(mList.getWidth(), mList.getHeight(), 0, 0);
            }
            mState = STATE_NONE;
            refreshDrawableState();
            ta.recycle();
            mScaledTouchSlop = android.view.ViewConfiguration.get(context).getScaledTouchSlop
                                   ();
            mMatchDragPosition = context.getApplicationInfo().targetSdkVersion >= android.os.Build
                                 .VERSION_CODES.HONEYCOMB;
            setScrollbarPosition(mList.getVerticalScrollbarPosition());
        }
Example #19
0
        /// <summary><inheritDoc></inheritDoc></summary>
        public RadioGroup(android.content.Context context, android.util.AttributeSet attrs
                          ) : base(context, attrs)
        {
            // retrieve selected radio button as requested by the user in the
            // XML layout file
            android.content.res.TypedArray attributes = context.obtainStyledAttributes(attrs,
                                                                                       [email protected], [email protected]
                                                                                       , 0);
            int value = attributes.getResourceId([email protected]_checkedButton
                                                 , android.view.View.NO_ID);

            if (value != android.view.View.NO_ID)
            {
                mCheckedId = value;
            }
            int index = attributes.getInt([email protected]_orientation
                                          , VERTICAL);

            setOrientation(index);
            attributes.recycle();
            init();
        }
Example #20
0
        public override void inflate(android.content.res.Resources r, org.xmlpull.v1.XmlPullParser
                                     parser, android.util.AttributeSet attrs)
        {
            android.content.res.TypedArray a = r.obtainAttributes(attrs, [email protected].
                                                                  styleable.AnimatedRotateDrawable);
            base.inflateWithAttributes(r, parser, a, [email protected]_visible
                                       );
            android.util.TypedValue tv = a.peekValue([email protected]_pivotX
                                                     );
            bool  pivotXRel = tv.type == android.util.TypedValue.TYPE_FRACTION;
            float pivotX    = pivotXRel ? tv.getFraction(1.0f, 1.0f) : tv.getFloat();

            tv = a.peekValue([email protected]_pivotY);
            bool  pivotYRel = tv.type == android.util.TypedValue.TYPE_FRACTION;
            float pivotY    = pivotYRel ? tv.getFraction(1.0f, 1.0f) : tv.getFloat();

            setFramesCount(a.getInt([email protected]_framesCount
                                    , 12));
            setFramesDuration(a.getInt([email protected]_frameDuration
                                       , 150));
            int res = a.getResourceId([email protected]_drawable
                                      , 0);

            android.graphics.drawable.Drawable drawable = null;
            if (res > 0)
            {
                drawable = r.getDrawable(res);
            }
            a.recycle();
            int outerDepth = parser.getDepth();
            int type;

            while ((type = parser.next()) != org.xmlpull.v1.XmlPullParserClass.END_DOCUMENT &&
                   (type != org.xmlpull.v1.XmlPullParserClass.END_TAG || parser.getDepth() > outerDepth
                   ))
            {
                if (type != org.xmlpull.v1.XmlPullParserClass.START_TAG)
                {
                    continue;
                }
                if ((drawable = android.graphics.drawable.Drawable.createFromXmlInner(r, parser,
                                                                                      attrs)) == null)
                {
                    android.util.Log.w("drawable", "Bad element under <animated-rotate>: " + parser.getName
                                           ());
                }
            }
            if (drawable == null)
            {
                android.util.Log.w("drawable", "No drawable specified for <animated-rotate>");
            }
            android.graphics.drawable.AnimatedRotateDrawable.AnimatedRotateState rotateState =
                mState;
            rotateState.mDrawable  = drawable;
            rotateState.mPivotXRel = pivotXRel;
            rotateState.mPivotX    = pivotX;
            rotateState.mPivotYRel = pivotYRel;
            rotateState.mPivotY    = pivotY;
            init();
            if (drawable != null)
            {
                drawable.setCallback(this);
            }
        }
Example #21
0
        public override void inflate(android.content.res.Resources r, org.xmlpull.v1.XmlPullParser
                                     parser, android.util.AttributeSet attrs)
        {
            base.inflate(r, parser, attrs);
            int type;

            android.content.res.TypedArray a = r.obtainAttributes(attrs, [email protected].
                                                                  styleable.LayerDrawable);
            mOpacityOverride = a.getInt([email protected]_opacity,
                                        android.graphics.PixelFormat.UNKNOWN);
            a.recycle();
            int innerDepth = parser.getDepth() + 1;
            int depth;

            while ((type = parser.next()) != org.xmlpull.v1.XmlPullParserClass.END_DOCUMENT &&
                   ((depth = parser.getDepth()) >= innerDepth || type != org.xmlpull.v1.XmlPullParserClass.END_TAG
                   ))
            {
                if (type != org.xmlpull.v1.XmlPullParserClass.START_TAG)
                {
                    continue;
                }
                if (depth > innerDepth || !parser.getName().Equals("item"))
                {
                    continue;
                }
                a = r.obtainAttributes(attrs, [email protected]);
                int left = a.getDimensionPixelOffset([email protected]_left
                                                     , 0);
                int top = a.getDimensionPixelOffset([email protected]_top
                                                    , 0);
                int right = a.getDimensionPixelOffset([email protected]_right
                                                      , 0);
                int bottom = a.getDimensionPixelOffset([email protected]_bottom
                                                       , 0);
                int drawableRes = a.getResourceId([email protected]_drawable
                                                  , 0);
                int id = a.getResourceId([email protected]_id, android.view.View
                                         .NO_ID);
                a.recycle();
                android.graphics.drawable.Drawable dr;
                if (drawableRes != 0)
                {
                    dr = r.getDrawable(drawableRes);
                }
                else
                {
                    while ((type = parser.next()) == org.xmlpull.v1.XmlPullParserClass.TEXT)
                    {
                    }
                    if (type != org.xmlpull.v1.XmlPullParserClass.START_TAG)
                    {
                        throw new org.xmlpull.v1.XmlPullParserException(parser.getPositionDescription() +
                                                                        ": <item> tag requires a 'drawable' attribute or " + "child tag defining a drawable"
                                                                        );
                    }
                    dr = android.graphics.drawable.Drawable.createFromXmlInner(r, parser, attrs);
                }
                addLayer(dr, id, left, top, right, bottom);
            }
            ensurePadding();
            onStateChange(getState());
        }
Example #22
0
        public override void inflate(android.content.res.Resources r, org.xmlpull.v1.XmlPullParser
                                     parser, android.util.AttributeSet attrs)
        {
            android.content.res.TypedArray a = r.obtainAttributes(attrs, [email protected].
                                                                  styleable.StateListDrawable);
            base.inflateWithAttributes(r, parser, a, [email protected]_visible
                                       );
            mStateListState.setVariablePadding(a.getBoolean([email protected]_variablePadding
                                                            , false));
            mStateListState.setConstantSize(a.getBoolean([email protected]_constantSize
                                                         , false));
            mStateListState.setEnterFadeDuration(a.getInt([email protected]_enterFadeDuration
                                                          , 0));
            mStateListState.setExitFadeDuration(a.getInt([email protected]_exitFadeDuration
                                                         , 0));
            setDither(a.getBoolean([email protected]_dither, DEFAULT_DITHER
                                   ));
            a.recycle();
            int type;
            int innerDepth = parser.getDepth() + 1;
            int depth;

            while ((type = parser.next()) != org.xmlpull.v1.XmlPullParserClass.END_DOCUMENT &&
                   ((depth = parser.getDepth()) >= innerDepth || type != org.xmlpull.v1.XmlPullParserClass.END_TAG
                   ))
            {
                if (type != org.xmlpull.v1.XmlPullParserClass.START_TAG)
                {
                    continue;
                }
                if (depth > innerDepth || !parser.getName().Equals("item"))
                {
                    continue;
                }
                int   drawableRes = 0;
                int   i;
                int   j        = 0;
                int   numAttrs = attrs.getAttributeCount();
                int[] states   = new int[numAttrs];
                for (i = 0; i < numAttrs; i++)
                {
                    int stateResId = attrs.getAttributeNameResource(i);
                    if (stateResId == 0)
                    {
                        break;
                    }
                    if (stateResId == [email protected])
                    {
                        drawableRes = attrs.getAttributeResourceValue(i, 0);
                    }
                    else
                    {
                        states[j++] = attrs.getAttributeBooleanValue(i, false) ? stateResId : -stateResId;
                    }
                }
                states = android.util.StateSet.trimStateSet(states, j);
                android.graphics.drawable.Drawable dr;
                if (drawableRes != 0)
                {
                    dr = r.getDrawable(drawableRes);
                }
                else
                {
                    while ((type = parser.next()) == org.xmlpull.v1.XmlPullParserClass.TEXT)
                    {
                    }
                    if (type != org.xmlpull.v1.XmlPullParserClass.START_TAG)
                    {
                        throw new org.xmlpull.v1.XmlPullParserException(parser.getPositionDescription() +
                                                                        ": <item> tag requires a 'drawable' attribute or " + "child tag defining a drawable"
                                                                        );
                    }
                    dr = android.graphics.drawable.Drawable.createFromXmlInner(r, parser, attrs);
                }
                mStateListState.addStateSet(states, dr);
            }
            onStateChange(getState());
        }
Example #23
0
        public override void inflate(android.content.res.Resources r, org.xmlpull.v1.XmlPullParser
                                     parser, android.util.AttributeSet attrs)
        {
            base.inflate(r, parser, attrs);
            android.content.res.TypedArray a = r.obtainAttributes(attrs, [email protected].
                                                                  styleable.BitmapDrawable);
            int id = a.getResourceId([email protected]_src, 0);

            if (id == 0)
            {
                throw new org.xmlpull.v1.XmlPullParserException(parser.getPositionDescription() +
                                                                ": <bitmap> requires a valid src attribute");
            }
            android.graphics.Bitmap bitmap = android.graphics.BitmapFactory.decodeResource(r,
                                                                                           id);
            if (bitmap == null)
            {
                throw new org.xmlpull.v1.XmlPullParserException(parser.getPositionDescription() +
                                                                ": <bitmap> requires a valid src attribute");
            }
            mBitmapState.mBitmap = bitmap;
            setBitmap(bitmap);
            setTargetDensity(r.getDisplayMetrics());
            android.graphics.Paint paint = mBitmapState.mPaint;
            paint.setAntiAlias(a.getBoolean([email protected]_antialias
                                            , paint.isAntiAlias()));
            paint.setFilterBitmap(a.getBoolean([email protected]_filter
                                               , paint.isFilterBitmap()));
            paint.setDither(a.getBoolean([email protected]_dither,
                                         paint.isDither()));
            setGravity(a.getInt([email protected]_gravity, android.view.Gravity
                                .FILL));
            int tileMode = a.getInt([email protected]_tileMode, -1
                                    );

            if (tileMode != -1)
            {
                switch (tileMode)
                {
                case 0:
                {
                    setTileModeXY(android.graphics.Shader.TileMode.CLAMP, android.graphics.Shader.TileMode
                                  .CLAMP);
                    break;
                }

                case 1:
                {
                    setTileModeXY(android.graphics.Shader.TileMode.REPEAT, android.graphics.Shader.TileMode
                                  .REPEAT);
                    break;
                }

                case 2:
                {
                    setTileModeXY(android.graphics.Shader.TileMode.MIRROR, android.graphics.Shader.TileMode
                                  .MIRROR);
                    break;
                }
                }
            }
            a.recycle();
        }
Example #24
0
        /// <summary>
        /// Creates a new animation whose parameters come from the specified context and
        /// attributes set.
        /// </summary>
        /// <remarks>
        /// Creates a new animation whose parameters come from the specified context and
        /// attributes set.
        /// </remarks>
        /// <param name="context">the application environment</param>
        /// <param name="attrs">the set of attributes holding the animation parameters</param>
        /// <exception cref="android.content.res.Resources.NotFoundException"></exception>
        private static android.animation.ValueAnimator loadAnimator(android.content.Context
                                                                    context, android.util.AttributeSet attrs, android.animation.ValueAnimator anim)
        {
            android.content.res.TypedArray a = context.obtainStyledAttributes(attrs, [email protected]
                                                                              .styleable.Animator);
            long duration   = a.getInt([email protected]_duration, 0);
            long startDelay = a.getInt([email protected]_startOffset, 0);
            int  valueType  = a.getInt([email protected]_valueType, VALUE_TYPE_FLOAT
                                       );

            if (anim == null)
            {
                anim = new android.animation.ValueAnimator();
            }
            android.animation.TypeEvaluator <object> evaluator = null;
            int  valueFromIndex = [email protected]_valueFrom;
            int  valueToIndex   = [email protected]_valueTo;
            bool getFloats      = (valueType == VALUE_TYPE_FLOAT);

            android.util.TypedValue tvFrom = a.peekValue(valueFromIndex);
            bool hasFrom  = (tvFrom != null);
            int  fromType = hasFrom ? tvFrom.type : 0;

            android.util.TypedValue tvTo = a.peekValue(valueToIndex);
            bool hasTo  = (tvTo != null);
            int  toType = hasTo ? tvTo.type : 0;

            if ((hasFrom && (fromType >= android.util.TypedValue.TYPE_FIRST_COLOR_INT) && (fromType
                                                                                           <= android.util.TypedValue.TYPE_LAST_COLOR_INT)) || (hasTo && (toType >= android.util.TypedValue
                                                                                                                                                          .TYPE_FIRST_COLOR_INT) && (toType <= android.util.TypedValue.TYPE_LAST_COLOR_INT
                                                                                                                                                                                     )))
            {
                // special case for colors: ignore valueType and get ints
                getFloats = false;
                anim.setEvaluator(new android.animation.ArgbEvaluator());
            }
            if (getFloats)
            {
                float valueFrom;
                float valueTo;
                if (hasFrom)
                {
                    if (fromType == android.util.TypedValue.TYPE_DIMENSION)
                    {
                        valueFrom = a.getDimension(valueFromIndex, 0f);
                    }
                    else
                    {
                        valueFrom = a.getFloat(valueFromIndex, 0f);
                    }
                    if (hasTo)
                    {
                        if (toType == android.util.TypedValue.TYPE_DIMENSION)
                        {
                            valueTo = a.getDimension(valueToIndex, 0f);
                        }
                        else
                        {
                            valueTo = a.getFloat(valueToIndex, 0f);
                        }
                        anim.setFloatValues(valueFrom, valueTo);
                    }
                    else
                    {
                        anim.setFloatValues(valueFrom);
                    }
                }
                else
                {
                    if (toType == android.util.TypedValue.TYPE_DIMENSION)
                    {
                        valueTo = a.getDimension(valueToIndex, 0f);
                    }
                    else
                    {
                        valueTo = a.getFloat(valueToIndex, 0f);
                    }
                    anim.setFloatValues(valueTo);
                }
            }
            else
            {
                int valueFrom;
                int valueTo;
                if (hasFrom)
                {
                    if (fromType == android.util.TypedValue.TYPE_DIMENSION)
                    {
                        valueFrom = (int)a.getDimension(valueFromIndex, 0f);
                    }
                    else
                    {
                        if ((fromType >= android.util.TypedValue.TYPE_FIRST_COLOR_INT) && (fromType <= android.util.TypedValue
                                                                                           .TYPE_LAST_COLOR_INT))
                        {
                            valueFrom = a.getColor(valueFromIndex, 0);
                        }
                        else
                        {
                            valueFrom = a.getInt(valueFromIndex, 0);
                        }
                    }
                    if (hasTo)
                    {
                        if (toType == android.util.TypedValue.TYPE_DIMENSION)
                        {
                            valueTo = (int)a.getDimension(valueToIndex, 0f);
                        }
                        else
                        {
                            if ((toType >= android.util.TypedValue.TYPE_FIRST_COLOR_INT) && (toType <= android.util.TypedValue
                                                                                             .TYPE_LAST_COLOR_INT))
                            {
                                valueTo = a.getColor(valueToIndex, 0);
                            }
                            else
                            {
                                valueTo = a.getInt(valueToIndex, 0);
                            }
                        }
                        anim.setIntValues(valueFrom, valueTo);
                    }
                    else
                    {
                        anim.setIntValues(valueFrom);
                    }
                }
                else
                {
                    if (hasTo)
                    {
                        if (toType == android.util.TypedValue.TYPE_DIMENSION)
                        {
                            valueTo = (int)a.getDimension(valueToIndex, 0f);
                        }
                        else
                        {
                            if ((toType >= android.util.TypedValue.TYPE_FIRST_COLOR_INT) && (toType <= android.util.TypedValue
                                                                                             .TYPE_LAST_COLOR_INT))
                            {
                                valueTo = a.getColor(valueToIndex, 0);
                            }
                            else
                            {
                                valueTo = a.getInt(valueToIndex, 0);
                            }
                        }
                        anim.setIntValues(valueTo);
                    }
                }
            }
            anim.setDuration(duration);
            anim.setStartDelay(startDelay);
            if (a.hasValue([email protected]_repeatCount))
            {
                anim.setRepeatCount(a.getInt([email protected]_repeatCount,
                                             0));
            }
            if (a.hasValue([email protected]_repeatMode))
            {
                anim.setRepeatMode(a.getInt([email protected]_repeatMode, android.animation.ValueAnimator
                                            .RESTART));
            }
            if (evaluator != null)
            {
                anim.setEvaluator(evaluator);
            }
            int resID = a.getResourceId([email protected]_interpolator,
                                        0);

            if (resID > 0)
            {
                anim.setInterpolator(android.view.animation.AnimationUtils.loadInterpolator(context
                                                                                            , resID));
            }
            a.recycle();
            return(anim);
        }
Example #25
0
        /// <exception cref="org.xmlpull.v1.XmlPullParserException"></exception>
        /// <exception cref="System.IO.IOException"></exception>
        private static android.animation.Animator createAnimatorFromXml(android.content.Context
                                                                        c, org.xmlpull.v1.XmlPullParser parser, android.util.AttributeSet attrs, android.animation.AnimatorSet
                                                                        parent, int sequenceOrdering)
        {
            android.animation.Animator anim = null;
            java.util.ArrayList <android.animation.Animator> childAnims = null;
            // Make sure we are on a start tag.
            int type;
            int depth = parser.getDepth();

            while (((type = parser.next()) != org.xmlpull.v1.XmlPullParserClass.END_TAG || parser
                    .getDepth() > depth) && type != org.xmlpull.v1.XmlPullParserClass.END_DOCUMENT)
            {
                if (type != org.xmlpull.v1.XmlPullParserClass.START_TAG)
                {
                    continue;
                }
                string name = parser.getName();
                if (name.Equals("objectAnimator"))
                {
                    anim = loadObjectAnimator(c, attrs);
                }
                else
                {
                    if (name.Equals("animator"))
                    {
                        anim = loadAnimator(c, attrs, null);
                    }
                    else
                    {
                        if (name.Equals("set"))
                        {
                            anim = new android.animation.AnimatorSet();
                            android.content.res.TypedArray a = c.obtainStyledAttributes(attrs, [email protected]
                                                                                        .styleable.AnimatorSet);
                            int ordering = a.getInt([email protected]_ordering, TOGETHER
                                                    );
                            createAnimatorFromXml(c, parser, attrs, (android.animation.AnimatorSet)anim, ordering
                                                  );
                            a.recycle();
                        }
                        else
                        {
                            throw new java.lang.RuntimeException("Unknown animator name: " + parser.getName()
                                                                 );
                        }
                    }
                }
                if (parent != null)
                {
                    if (childAnims == null)
                    {
                        childAnims = new java.util.ArrayList <android.animation.Animator>();
                    }
                    childAnims.add(anim);
                }
            }
            if (parent != null && childAnims != null)
            {
                android.animation.Animator[] animsArray = new android.animation.Animator[childAnims
                                                                                         .size()];
                int index = 0;
                foreach (android.animation.Animator a in Sharpen.IterableProxy.Create(childAnims))
                {
                    animsArray[index++] = a;
                }
                if (sequenceOrdering == TOGETHER)
                {
                    parent.playTogether(animsArray);
                }
                else
                {
                    parent.playSequentially(animsArray);
                }
            }
            return(anim);
        }
Example #26
0
        public override void inflate(android.content.res.Resources r, org.xmlpull.v1.XmlPullParser
                                     parser, android.util.AttributeSet attrs)
        {
            android.content.res.TypedArray a = r.obtainAttributes(attrs, [email protected].
                                                                  styleable.AnimationDrawable);
            base.inflateWithAttributes(r, parser, a, [email protected]_visible
                                       );
            mAnimationState.setVariablePadding(a.getBoolean([email protected]_variablePadding
                                                            , false));
            mAnimationState.mOneShot = a.getBoolean([email protected]_oneshot
                                                    , false);
            a.recycle();
            int type;
            int innerDepth = parser.getDepth() + 1;
            int depth;

            while ((type = parser.next()) != org.xmlpull.v1.XmlPullParserClass.END_DOCUMENT &&
                   ((depth = parser.getDepth()) >= innerDepth || type != org.xmlpull.v1.XmlPullParserClass.END_TAG
                   ))
            {
                if (type != org.xmlpull.v1.XmlPullParserClass.START_TAG)
                {
                    continue;
                }
                if (depth > innerDepth || !parser.getName().Equals("item"))
                {
                    continue;
                }
                a = r.obtainAttributes(attrs, [email protected]
                                       );
                int duration = a.getInt([email protected]_duration
                                        , -1);
                if (duration < 0)
                {
                    throw new org.xmlpull.v1.XmlPullParserException(parser.getPositionDescription() +
                                                                    ": <item> tag requires a 'duration' attribute");
                }
                int drawableRes = a.getResourceId([email protected]_drawable
                                                  , 0);
                a.recycle();
                android.graphics.drawable.Drawable dr;
                if (drawableRes != 0)
                {
                    dr = r.getDrawable(drawableRes);
                }
                else
                {
                    while ((type = parser.next()) == org.xmlpull.v1.XmlPullParserClass.TEXT)
                    {
                    }
                    // Empty
                    if (type != org.xmlpull.v1.XmlPullParserClass.START_TAG)
                    {
                        throw new org.xmlpull.v1.XmlPullParserException(parser.getPositionDescription() +
                                                                        ": <item> tag requires a 'drawable' attribute or child tag" + " defining a drawable"
                                                                        );
                    }
                    dr = android.graphics.drawable.Drawable.createFromXmlInner(r, parser, attrs);
                }
                mAnimationState.addFrame(dr, duration);
                if (dr != null)
                {
                    dr.setCallback(this);
                }
            }
            setFrame(0, true, false);
        }