/// <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();
        }
Ejemplo n.º 2
0
        public ViewAnimator(android.content.Context context, android.util.AttributeSet attrs
                            ) : base(context, attrs)
        {
            android.content.res.TypedArray a = context.obtainStyledAttributes(attrs, [email protected]
                                                                              .styleable.ViewAnimator);
            int resource = a.getResourceId([email protected]_inAnimation
                                           , 0);

            if (resource > 0)
            {
                setInAnimation(context, resource);
            }
            resource = a.getResourceId([email protected]_outAnimation
                                       , 0);
            if (resource > 0)
            {
                setOutAnimation(context, resource);
            }
            bool flag = a.getBoolean([email protected]_animateFirstView
                                     , true);

            setAnimateFirstView(flag);
            a.recycle();
            initViewAnimator(context, attrs);
        }
Ejemplo n.º 3
0
 public ViewStub(android.content.Context context, android.util.AttributeSet attrs,
                 int defStyle)
 {
     android.content.res.TypedArray a = context.obtainStyledAttributes(attrs, [email protected]
                                                                       .styleable.ViewStub, defStyle, 0);
     mInflatedId = a.getResourceId([email protected]_inflatedId,
                                   NO_ID);
     mLayoutResource = a.getResourceId([email protected]_layout,
                                       0);
     a.recycle();
     a = context.obtainStyledAttributes(attrs, [email protected], defStyle
                                        , 0);
     mID = a.getResourceId([email protected]_id, NO_ID);
     a.recycle();
     initialize(context);
 }
Ejemplo n.º 4
0
 public ActionBarContextView(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.ActionMode, defStyle, 0);
     setBackgroundDrawable(a.getDrawable([email protected]_background
                                         ));
     mTitleStyleRes = a.getResourceId([email protected]_titleTextStyle
                                      , 0);
     mSubtitleStyleRes = a.getResourceId([email protected]_subtitleTextStyle
                                         , 0);
     mContentHeight = a.getLayoutDimension([email protected]_height
                                           , 0);
     mSplitBackground = a.getDrawable([email protected]_backgroundSplit
                                      );
     a.recycle();
 }
Ejemplo n.º 5
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());
        }
Ejemplo n.º 6
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.NinePatchDrawable);
            int id = a.getResourceId([email protected]_src, 0);

            if (id == 0)
            {
                throw new org.xmlpull.v1.XmlPullParserException(parser.getPositionDescription() +
                                                                ": <nine-patch> requires a valid src attribute");
            }
            bool dither = a.getBoolean([email protected]_dither
                                       , DEFAULT_DITHER);

            android.graphics.BitmapFactory.Options options = new android.graphics.BitmapFactory
                                                             .Options();
            if (dither)
            {
                options.inDither = false;
            }
            options.inScreenDensity = android.util.DisplayMetrics.DENSITY_DEVICE;
            android.graphics.Rect   padding = new android.graphics.Rect();
            android.graphics.Bitmap bitmap  = null;
            try
            {
                android.util.TypedValue value = new android.util.TypedValue();
                java.io.InputStream     @is   = r.openRawResource(id, value);
                bitmap = android.graphics.BitmapFactory.decodeResourceStream(r, value, @is, padding
                                                                             , options);
                @is.close();
            }
            catch (System.IO.IOException)
            {
            }
            // Ignore
            if (bitmap == null)
            {
                throw new org.xmlpull.v1.XmlPullParserException(parser.getPositionDescription() +
                                                                ": <nine-patch> requires a valid src attribute");
            }
            else
            {
                if (bitmap.getNinePatchChunk() == null)
                {
                    throw new org.xmlpull.v1.XmlPullParserException(parser.getPositionDescription() +
                                                                    ": <nine-patch> requires a valid 9-patch source image");
                }
            }
            setNinePatchState(new android.graphics.drawable.NinePatchDrawable.NinePatchState(
                                  new android.graphics.NinePatch(bitmap, bitmap.getNinePatchChunk(), "XML 9-patch"
                                                                 ), padding, dither), r);
            mNinePatchState.mTargetDensity = mTargetDensity;
            a.recycle();
        }
Ejemplo n.º 7
0
 /// <summary>Instantiates the ExpandedMenuView that is linked with the provided MenuBuilder.
 ///     </summary>
 /// <remarks>Instantiates the ExpandedMenuView that is linked with the provided MenuBuilder.
 ///     </remarks>
 /// <param name="menu">The model for the menu which this MenuView will display</param>
 public ExpandedMenuView(android.content.Context context, android.util.AttributeSet
                         attrs) : base(context, attrs)
 {
     android.content.res.TypedArray a = context.obtainStyledAttributes(attrs, [email protected]
                                                                       .styleable.MenuView, 0, 0);
     mAnimations = a.getResourceId([email protected]_windowAnimationStyle
                                   , 0);
     a.recycle();
     setOnItemClickListener(this);
 }
Ejemplo n.º 8
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);
 }
Ejemplo n.º 9
0
 public AlertController(android.content.Context context, android.content.DialogInterface
                        di, android.view.Window window)
 {
     mButtonHandler   = new _OnClickListener_129(this);
     mContext         = context;
     mDialogInterface = di;
     mWindow          = window;
     mHandler         = new [email protected](di);
     android.content.res.TypedArray a = context.obtainStyledAttributes(null, [email protected]
                                                                       .styleable.AlertDialog, [email protected], 0);
     mAlertDialogLayout = a.getResourceId([email protected]_layout
                                          , [email protected]_dialog);
     mListLayout = a.getResourceId([email protected]_listLayout
                                   , [email protected]_dialog);
     mMultiChoiceItemLayout = a.getResourceId([email protected]_multiChoiceItemLayout
                                              , [email protected]_dialog_multichoice);
     mSingleChoiceItemLayout = a.getResourceId([email protected]_singleChoiceItemLayout
                                               , [email protected]_dialog_singlechoice);
     mListItemLayout = a.getResourceId([email protected]_listItemLayout
                                       , [email protected]_dialog_item);
     a.recycle();
 }
Ejemplo n.º 10
0
 public ListMenuItemView(android.content.Context context, android.util.AttributeSet
                         attrs, int defStyle) : base(context, attrs)
 {
     android.content.res.TypedArray a = context.obtainStyledAttributes(attrs, [email protected]
                                                                       .styleable.MenuView, defStyle, 0);
     mBackground = a.getDrawable([email protected]_itemBackground
                                 );
     mTextAppearance = a.getResourceId([email protected]_itemTextAppearance
                                       , -1);
     mPreserveIconSpacing = a.getBoolean([email protected]_preserveIconSpacing
                                         , false);
     mTextAppearanceContext = context;
     a.recycle();
 }
Ejemplo n.º 11
0
 public TabHost(android.content.Context context, android.util.AttributeSet attrs) :
     base(context, attrs)
 {
     android.content.res.TypedArray a = context.obtainStyledAttributes(attrs, [email protected]
                                                                       .styleable.TabWidget, [email protected], 0);
     mTabLayoutId = a.getResourceId([email protected]_tabLayout,
                                    0);
     a.recycle();
     if (mTabLayoutId == 0)
     {
         // In case the tabWidgetStyle does not inherit from Widget.TabWidget and tabLayout is
         // not defined.
         mTabLayoutId = [email protected]_indicator_holo;
     }
     initTabHost();
 }
Ejemplo n.º 12
0
 public IconMenuItemView(android.content.Context context, android.util.AttributeSet
                         attrs, int defStyle) : base(context, attrs)
 {
     if (sPrependShortcutLabel == null)
     {
         sPrependShortcutLabel = getResources().getString([email protected][email protected]_shortcut_label
                                                          );
     }
     android.content.res.TypedArray a = context.obtainStyledAttributes(attrs, [email protected]
                                                                       .styleable.MenuView, defStyle, 0);
     mDisabledAlpha = a.getFloat([email protected]_itemIconDisabledAlpha
                                 , 0.8f);
     mTextAppearance = a.getResourceId([email protected]_itemTextAppearance
                                       , -1);
     mTextAppearanceContext = context;
     a.recycle();
 }
Ejemplo n.º 13
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();
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Construct a new Switch with a default style determined by the given theme attribute,
        /// overriding specific style attributes as requested.
        /// </summary>
        /// <remarks>
        /// Construct a new Switch with a default style determined by the given theme attribute,
        /// overriding specific style attributes as requested.
        /// </remarks>
        /// <param name="context">The Context that will determine this widget's theming.</param>
        /// <param name="attrs">Specification of attributes that should deviate from the default styling.
        ///     </param>
        /// <param name="defStyle">
        /// An attribute ID within the active theme containing a reference to the
        /// default style for this widget. e.g. android.R.attr.switchStyle.
        /// </param>
        public Switch(android.content.Context context, android.util.AttributeSet attrs, int
                      defStyle) : base(context, attrs, defStyle)
        {
            // Enum for the "typeface" XML parameter.
            // Does not include padding
            mTextPaint = new android.text.TextPaint(android.graphics.Paint.ANTI_ALIAS_FLAG);
            android.content.res.Resources res = getResources();
            mTextPaint.density = res.getDisplayMetrics().density;
            mTextPaint.setCompatibilityScaling(res.getCompatibilityInfo().applicationScale);
            android.content.res.TypedArray a = context.obtainStyledAttributes(attrs, [email protected]
                                                                              .styleable.Switch, defStyle, 0);
            mThumbDrawable    = a.getDrawable([email protected]_thumb);
            mTrackDrawable    = a.getDrawable([email protected]_track);
            mTextOn           = a.getText([email protected]_textOn);
            mTextOff          = a.getText([email protected]_textOff);
            mThumbTextPadding = a.getDimensionPixelSize([email protected]_thumbTextPadding
                                                        , 0);
            mSwitchMinWidth = a.getDimensionPixelSize([email protected]_switchMinWidth
                                                      , 0);
            mSwitchPadding = a.getDimensionPixelSize([email protected]_switchPadding
                                                     , 0);
            int appearance = a.getResourceId([email protected]_switchTextAppearance
                                             , 0);

            if (appearance != 0)
            {
                setSwitchTextAppearance(context, appearance);
            }
            a.recycle();
            android.view.ViewConfiguration config = android.view.ViewConfiguration.get(context
                                                                                       );
            mTouchSlop        = config.getScaledTouchSlop();
            mMinFlingVelocity = config.getScaledMinimumFlingVelocity();
            // Refresh display with current params
            refreshDrawableState();
            setChecked(isChecked());
        }
Ejemplo n.º 15
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);
            }
        }
Ejemplo n.º 16
0
        public TimePicker(android.content.Context context, android.util.AttributeSet attrs
                          , int defStyle) : base(context, attrs, defStyle)
        {
            setCurrentLocale(System.Globalization.CultureInfo.CurrentCulture);
            android.content.res.TypedArray attributesArray = context.obtainStyledAttributes(attrs
                                                                                            , [email protected], defStyle, 0);
            int layoutResourceId = attributesArray.getResourceId([email protected]
                                                                 .TimePicker_layout, [email protected]_picker);

            attributesArray.recycle();
            android.view.LayoutInflater inflater = (android.view.LayoutInflater)context.getSystemService
                                                       (android.content.Context.LAYOUT_INFLATER_SERVICE);
            inflater.inflate(layoutResourceId, this, true);
            mHourSpinner = (android.widget.NumberPicker)findViewById([email protected]
                                                                     );
            mHourSpinner.setOnValueChangedListener(new _OnValueChangeListener_147(this));
            mHourSpinnerInput = (android.widget.EditText)mHourSpinner.findViewById([email protected]
                                                                                   .id.numberpicker_input);
            mHourSpinnerInput.setImeOptions(android.view.inputmethod.EditorInfo.IME_ACTION_NEXT
                                            );
            mDivider = (android.widget.TextView)findViewById([email protected]);
            if (mDivider != null)
            {
                mDivider.setText([email protected][email protected]_picker_separator);
            }
            mMinuteSpinner = (android.widget.NumberPicker)findViewById([email protected]
                                                                       .minute);
            mMinuteSpinner.setMinValue(0);
            mMinuteSpinner.setMaxValue(59);
            mMinuteSpinner.setOnLongPressUpdateInterval(100);
            mMinuteSpinner.setFormatter(android.widget.NumberPicker.TWO_DIGIT_FORMATTER);
            mMinuteSpinner.setOnValueChangedListener(new _OnValueChangeListener_175(this));
            mMinuteSpinnerInput = (android.widget.EditText)mMinuteSpinner.findViewById([email protected]
                                                                                       .id.numberpicker_input);
            mMinuteSpinnerInput.setImeOptions(android.view.inputmethod.EditorInfo.IME_ACTION_NEXT
                                              );
            mAmPmStrings = new java.text.DateFormatSymbols().getAmPmStrings();
            android.view.View amPmView = findViewById([email protected]);
            if (amPmView is android.widget.Button)
            {
                mAmPmSpinner      = null;
                mAmPmSpinnerInput = null;
                mAmPmButton       = (android.widget.Button)amPmView;
                mAmPmButton.setOnClickListener(new _OnClickListener_210(this));
            }
            else
            {
                mAmPmButton  = null;
                mAmPmSpinner = (android.widget.NumberPicker)amPmView;
                mAmPmSpinner.setMinValue(0);
                mAmPmSpinner.setMaxValue(1);
                mAmPmSpinner.setDisplayedValues(mAmPmStrings);
                mAmPmSpinner.setOnValueChangedListener(new _OnValueChangeListener_223(this));
                mAmPmSpinnerInput = (android.widget.EditText)mAmPmSpinner.findViewById([email protected]
                                                                                       .id.numberpicker_input);
                mAmPmSpinnerInput.setImeOptions(android.view.inputmethod.EditorInfo.IME_ACTION_DONE
                                                );
            }
            // update controls to initial state
            updateHourControl();
            updateAmPmControl();
            setOnTimeChangedListener(NO_OP_CHANGE_LISTENER);
            // set to current time
            setCurrentHour(mTempCalendar.get(java.util.Calendar.HOUR_OF_DAY));
            setCurrentMinute(mTempCalendar.get(java.util.Calendar.MINUTE));
            if (!isEnabled())
            {
                setEnabled(false);
            }
            // set the content descriptions
            setContentDescriptions();
        }
Ejemplo n.º 17
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();
        }
Ejemplo n.º 18
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());
        }
Ejemplo n.º 19
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);
        }
Ejemplo n.º 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.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);
        }
Ejemplo n.º 21
0
        private void setBackground(android.widget.LinearLayout topPanel, android.widget.LinearLayout
                                   contentPanel, android.view.View customPanel, bool hasButtons, android.content.res.TypedArray
                                   a, bool hasTitle, android.view.View buttonPanel)
        {
            int fullDark = a.getResourceId([email protected]_fullDark
                                           , [email protected]_full_dark);
            int topDark = a.getResourceId([email protected]_topDark,
                                          [email protected]_top_dark);
            int centerDark = a.getResourceId([email protected]_centerDark
                                             , [email protected]_center_dark);
            int bottomDark = a.getResourceId([email protected]_bottomDark
                                             , [email protected]_bottom_dark);
            int fullBright = a.getResourceId([email protected]_fullBright
                                             , [email protected]_full_bright);
            int topBright = a.getResourceId([email protected]_topBright
                                            , [email protected]_top_bright);
            int centerBright = a.getResourceId([email protected]_centerBright
                                               , [email protected]_center_bright);
            int bottomBright = a.getResourceId([email protected]_bottomBright
                                               , [email protected]_bottom_bright);
            int bottomMedium = a.getResourceId([email protected]_bottomMedium
                                               , [email protected]_bottom_medium);

            android.view.View[] views  = new android.view.View[4];
            bool[]            light    = new bool[4];
            android.view.View lastView = null;
            bool lastLight             = false;
            int  pos = 0;

            if (hasTitle)
            {
                views[pos] = topPanel;
                light[pos] = false;
                pos++;
            }
            views[pos] = (contentPanel.getVisibility() == android.view.View.GONE) ? null : contentPanel;
            light[pos] = mListView != null;
            pos++;
            if (customPanel != null)
            {
                views[pos] = customPanel;
                light[pos] = mForceInverseBackground;
                pos++;
            }
            if (hasButtons)
            {
                views[pos] = buttonPanel;
                light[pos] = true;
            }
            bool setView_1 = false;

            for (pos = 0; pos < views.Length; pos++)
            {
                android.view.View v = views[pos];
                if (v == null)
                {
                    continue;
                }
                if (lastView != null)
                {
                    if (!setView_1)
                    {
                        lastView.setBackgroundResource(lastLight ? topBright : topDark);
                    }
                    else
                    {
                        lastView.setBackgroundResource(lastLight ? centerBright : centerDark);
                    }
                    setView_1 = true;
                }
                lastView  = v;
                lastLight = light[pos];
            }
            if (lastView != null)
            {
                if (setView_1)
                {
                    lastView.setBackgroundResource(lastLight ? (hasButtons ? bottomMedium : bottomBright
                                                                ) : bottomDark);
                }
                else
                {
                    lastView.setBackgroundResource(lastLight ? fullBright : fullDark);
                }
            }
            //        if (hasButtons && (mListView != null)) {
            //        }
            if ((mListView != null) && (mAdapter != null))
            {
                mListView.setAdapter(mAdapter);
                if (mCheckedItem > -1)
                {
                    mListView.setItemChecked(mCheckedItem, true);
                    mListView.setSelection(mCheckedItem);
                }
            }
        }
Ejemplo n.º 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.RotateDrawable);
            base.inflateWithAttributes(r, parser, a, [email protected]_visible
                                       );
            android.util.TypedValue tv = a.peekValue([email protected]_pivotX
                                                     );
            bool  pivotXRel;
            float pivotX;

            if (tv == null)
            {
                pivotXRel = true;
                pivotX    = 0.5f;
            }
            else
            {
                pivotXRel = tv.type == android.util.TypedValue.TYPE_FRACTION;
                pivotX    = pivotXRel ? tv.getFraction(1.0f, 1.0f) : tv.getFloat();
            }
            tv = a.peekValue([email protected]_pivotY);
            bool  pivotYRel;
            float pivotY;

            if (tv == null)
            {
                pivotYRel = true;
                pivotY    = 0.5f;
            }
            else
            {
                pivotYRel = tv.type == android.util.TypedValue.TYPE_FRACTION;
                pivotY    = pivotYRel ? tv.getFraction(1.0f, 1.0f) : tv.getFloat();
            }
            float fromDegrees = a.getFloat([email protected]_fromDegrees
                                           , 0.0f);
            float toDegrees = a.getFloat([email protected]_toDegrees
                                         , 360.0f);
            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 <rotate>: " + parser.getName());
                }
            }
            if (drawable == null)
            {
                android.util.Log.w("drawable", "No drawable specified for <rotate>");
            }
            mState.mDrawable    = drawable;
            mState.mPivotXRel   = pivotXRel;
            mState.mPivotX      = pivotX;
            mState.mPivotYRel   = pivotYRel;
            mState.mPivotY      = pivotY;
            mState.mFromDegrees = mState.mCurrentDegrees = fromDegrees;
            mState.mToDegrees   = toDegrees;
            if (drawable != null)
            {
                drawable.setCallback(this);
            }
        }