Ejemplo n.º 1
0
        internal static void FillBoundView(IBoundView view, Context context, IAttributeSet attrs)
        {
            TypedArray attrArr = context.ObtainStyledAttributes(attrs, Resource.Styleable.BoundItem);

            view.Binding           = attrArr.GetString(Resource.Styleable.BoundItem_binding);
            view.VisibilityBinding = attrArr.GetString(Resource.Styleable.BoundItem_visibility_binding);
        }
Ejemplo n.º 2
0
        public ChipView(Context context, IAttributeSet attrs, int defStyleAttr) : base(context, attrs, defStyleAttr)
        {
            TypedArray a = context.Theme.ObtainStyledAttributes(attrs, Resource.Styleable.ChipView, defStyleAttr, 0);

            if (a.HasValue(Resource.Styleable.ChipView_chip_text))
            {
                _chipText = a.GetString(Resource.Styleable.ChipView_chip_text);
            }
            _hasIcon = a.GetBoolean(Resource.Styleable.ChipView_enable_icon, false);
            if (a.HasValue(Resource.Styleable.ChipView_chip_icon))
            {
                _chipIcon = a.GetDrawable(Resource.Styleable.ChipView_chip_icon);
            }
            _closable                = a.GetBoolean(Resource.Styleable.ChipView_closeable, false);
            _selectable              = a.GetBoolean(Resource.Styleable.ChipView_chip_selectable, false);
            _backgroundColor         = a.GetColor(Resource.Styleable.ChipView_chip_backgroundColor, ContextCompat.GetColor(context, Resource.Color.default_chip_background_color));
            _selectedBackgroundColor = a.GetColor(Resource.Styleable.ChipView_chip_selectedBackgroundColor, ContextCompat.GetColor(context, Resource.Color.default_chip_background_clicked_color));
            _textColor               = a.GetColor(Resource.Styleable.ChipView_chip_text_color, ContextCompat.GetColor(context, Resource.Color.default_chip_text_color));
            _selectedTextColor       = a.GetColor(Resource.Styleable.ChipView_chip_selected_text_color, ContextCompat.GetColor(context, Resource.Color.default_chip_text_clicked_color));
            _closeColor              = a.GetColor(Resource.Styleable.ChipView_chip_close_color, ContextCompat.GetColor(context, Resource.Color.default_chip_close_inactive_color));
            _selectedCloseColor      = a.GetColor(Resource.Styleable.ChipView_chip_selected_close_color, ContextCompat.GetColor(context, Resource.Color.default_chip_close_clicked_color));
            _cornerRadius            = (int)a.GetDimension(Resource.Styleable.ChipView_chip_cornerRadius, Resources.GetDimension(Resource.Dimension.chip_height) / 2);
            _strokeSize              = (int)a.GetDimension(Resource.Styleable.ChipView_chip_strokeSize, 0);
            _strokeColor             = a.GetColor(Resource.Styleable.ChipView_chip_strokeColor, ContextCompat.GetColor(context, Resource.Color.default_chip_close_clicked_color));
            if (a.HasValue(Resource.Styleable.ChipView_chip_iconText))
            {
                _iconText = a.GetString(Resource.Styleable.ChipView_chip_iconText);
            }
            _iconTextColor           = a.GetColor(Resource.Styleable.ChipView_chip_iconTextColor, ContextCompat.GetColor(context, Resource.Color.default_chip_background_clicked_color));
            _iconTextBackgroundColor = a.GetColor(Resource.Styleable.ChipView_chip_iconTextBackgroundColor, ContextCompat.GetColor(context, Resource.Color.default_chip_close_clicked_color));
            a.Recycle();
            InitalizeViews(context);
        }
        private void initAttributes(Context context, IAttributeSet attributeSet)
        {
            TypedArray attr = getTypedArray(context, attributeSet, Resource.Styleable.ProcessButton);

            if (attr == null)
            {
                return;
            }

            try {
                mLoadingText  = attr.GetString(Resource.Styleable.ProcessButton_pb_textProgress);
                mCompleteText = attr.GetString(Resource.Styleable.ProcessButton_pb_textComplete);
                mErrorText    = attr.GetString(Resource.Styleable.ProcessButton_pb_textError);

                int purple        = getColor(Resource.Color.purple_progress);
                int colorProgress = attr.GetColor(Resource.Styleable.ProcessButton_pb_colorProgress, purple);
                mProgressDrawable.SetColor(colorProgress);

                int green         = getColor(Resource.Color.green_complete);
                int colorComplete = attr.GetColor(Resource.Styleable.ProcessButton_pb_colorComplete, green);
                mCompleteDrawable.SetColor(colorComplete);

                int red        = getColor(Resource.Color.red_error);
                int colorError = attr.GetColor(Resource.Styleable.ProcessButton_pb_colorError, red);
                mErrorDrawable.SetColor(colorError);
            } finally {
                attr.Recycle();
            }
        }
Ejemplo n.º 4
0
        private void Init(Context context, IAttributeSet attrs)
        {
            ConstructModel();
            counterTextViewModel.stop = fixedStop;
            elapsedSecond             = fixedStop;
            TypedArray ta = context.ObtainStyledAttributes(attrs, Resource.Styleable.CounterTextView, 0, 0);

            try
            {
                counterTextViewModel.progression = ta.GetInt(Resource.Styleable.CounterTextView_progression, 1);
                counterTextViewModel.stop        = ta.GetInt(Resource.Styleable.CounterTextView_stop, -11111111);
                counterTextViewModel.StopText    = ta.GetString(Resource.Styleable.CounterTextView_stopText);
                counterTextViewModel.start       = ta.GetInt(Resource.Styleable.CounterTextView_start, 0);
                counterTextViewModel.StartText   = ta.GetString(Resource.Styleable.CounterTextView_startText);
                counterTextViewModel.interval    = ta.GetInt(Resource.Styleable.CounterTextView_interval, 1000);
                counterTextViewModel.future      = ta.GetInt(Resource.Styleable.CounterTextView_future, 0);
                counterTextViewModel.repeat      = ta.GetBoolean(Resource.Styleable.CounterTextView_repeat, false);
                if (counterTextViewModel.future > 0)
                {
                    futureDone = true;
                }
            }
            finally
            {
                ta.Recycle();
            }
            lastnumber = counterTextViewModel.start;;
            SetText();
        }
Ejemplo n.º 5
0
        private void ReadAttrs(Context context, IAttributeSet attrs, int defStyle)
        {
            TypedArray typedArray = context.ObtainStyledAttributes(attrs, Resource.Styleable.GaugeView, defStyle, 0);

            mShowOuterShadow = typedArray.GetBoolean(Resource.Styleable.GaugeView_showOuterShadow, SHOW_OUTER_SHADOW);
            mShowOuterBorder = typedArray.GetBoolean(Resource.Styleable.GaugeView_showOuterBorder, SHOW_OUTER_BORDER);
            mShowOuterRim    = typedArray.GetBoolean(Resource.Styleable.GaugeView_showOuterRim, SHOW_OUTER_RIM);
            mShowInnerRim    = typedArray.GetBoolean(Resource.Styleable.GaugeView_showInnerRim, SHOW_INNER_RIM);
            mShowNeedle      = typedArray.GetBoolean(Resource.Styleable.GaugeView_showNeedle, SHOW_NEEDLE);
            mShowScale       = typedArray.GetBoolean(Resource.Styleable.GaugeView_showScale, SHOW_SCALE);
            mShowRanges      = typedArray.GetBoolean(Resource.Styleable.GaugeView_showRanges, SHOW_RANGES);
            mShowText        = typedArray.GetBoolean(Resource.Styleable.GaugeView_showText, SHOW_TEXT);

            mOuterShadowWidth    = mShowOuterShadow ? typedArray.GetFloat(Resource.Styleable.GaugeView_outerShadowWidth, OUTER_SHADOW_WIDTH) : 0.0f;
            mOuterBorderWidth    = mShowOuterBorder ? typedArray.GetFloat(Resource.Styleable.GaugeView_outerBorderWidth, OUTER_BORDER_WIDTH) : 0.0f;
            mOuterRimWidth       = mShowOuterRim ? typedArray.GetFloat(Resource.Styleable.GaugeView_outerRimWidth, OUTER_RIM_WIDTH) : 0.0f;
            mInnerRimWidth       = mShowInnerRim ? typedArray.GetFloat(Resource.Styleable.GaugeView_innerRimWidth, INNER_RIM_WIDTH) : 0.0f;
            mInnerRimBorderWidth = mShowInnerRim ? typedArray.GetFloat(Resource.Styleable.GaugeView_innerRimBorderWidth, INNER_RIM_BORDER_WIDTH) : 0.0f;

            mNeedleWidth  = typedArray.GetFloat(Resource.Styleable.GaugeView_needleWidth, NEEDLE_WIDTH);
            mNeedleHeight = typedArray.GetFloat(Resource.Styleable.GaugeView_needleHeight, NEEDLE_HEIGHT);

            mScalePosition   = (mShowScale || mShowRanges) ? typedArray.GetFloat(Resource.Styleable.GaugeView_scalePosition, SCALE_POSITION) : 0.0f;
            mScaleStartValue = typedArray.GetFloat(Resource.Styleable.GaugeView_scaleStartValue, SCALE_START_VALUE);
            mScaleEndValue   = typedArray.GetFloat(Resource.Styleable.GaugeView_scaleEndValue, SCALE_END_VALUE);
            mScaleStartAngle = typedArray.GetFloat(Resource.Styleable.GaugeView_scaleStartAngle, SCALE_START_ANGLE);
            mScaleEndAngle   = typedArray.GetFloat(Resource.Styleable.GaugeView_scaleEndAngle, 360.0f - mScaleStartAngle);

            mDivisions    = typedArray.GetInteger(Resource.Styleable.GaugeView_divisions, SCALE_DIVISIONS);
            mSubdivisions = typedArray.GetInteger(Resource.Styleable.GaugeView_subdivisions, SCALE_SUBDIVISIONS);

            if (mShowRanges)
            {
                mTextShadowColor = typedArray.GetColor(Resource.Styleable.GaugeView_textShadowColor, TEXT_SHADOW_COLOR);

                string[] rangeValues = typedArray.GetTextArray(Resource.Styleable.GaugeView_rangeValues);
                string[] rangeColors = typedArray.GetTextArray(Resource.Styleable.GaugeView_rangeColors);
                ReadRanges(rangeValues, rangeColors);
            }

            if (mShowText)
            {
                int    textValueId = typedArray.GetResourceId(Resource.Styleable.GaugeView_textValue, 0);
                string textValue   = typedArray.GetString(Resource.Styleable.GaugeView_textValue);
                mTextValue = (0 < textValueId) ? context.GetString(textValueId) : (null != textValue) ? textValue : "";

                int    textUnitId = typedArray.GetResourceId(Resource.Styleable.GaugeView_textUnit, 0);
                string textUnit   = typedArray.GetString(Resource.Styleable.GaugeView_textUnit);
                mTextUnit        = (0 < textUnitId) ? context.GetString(textUnitId) : (null != textUnit) ? textUnit : "";
                mTextValueColor  = typedArray.GetColor(Resource.Styleable.GaugeView_textValueColor, TEXT_VALUE_COLOR);
                mTextUnitColor   = typedArray.GetColor(Resource.Styleable.GaugeView_textUnitColor, TEXT_UNIT_COLOR);
                mTextShadowColor = typedArray.GetColor(Resource.Styleable.GaugeView_textShadowColor, TEXT_SHADOW_COLOR);

                mTextValueSize = typedArray.GetFloat(Resource.Styleable.GaugeView_textValueSize, TEXT_VALUE_SIZE);
                mTextUnitSize  = typedArray.GetFloat(Resource.Styleable.GaugeView_textUnitSize, TEXT_UNIT_SIZE);
            }

            typedArray.Recycle();
        }
Ejemplo n.º 6
0
        void Initialize(IAttributeSet attrs)
        {
            TypedArray a = Context.ObtainStyledAttributes(
                attrs,
                Resource.Styleable.Kp2aShortHelpView);

            TitleText = a.GetString(Resource.Styleable.Kp2aShortHelpView_title_text);
            HelpText  = a.GetString(Resource.Styleable.Kp2aShortHelpView_help_text);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Reads any attributes that were assigned in XML and sets properties appropriately
        /// </summary>
        /// <param name="typedArray">The attributes to apply to the view</param>
        private void InitializeAttributes(TypedArray typedArray)
        {
            string attrConditionName = typedArray.GetString(Resource.Styleable.ConditionResultView_condition_name);

            ConditionName = attrConditionName ?? "";

            Likelihood = typedArray.GetFloat(Resource.Styleable.ConditionResultView_condition_likelihood, 0);

            string attrLikelihoodLabel = typedArray.GetString(Resource.Styleable.ConditionResultView_condition_likelihood_label);

            LikelihoodLabel = attrLikelihoodLabel ?? "";
        }
        /// <summary>
        /// Inflates the views in the layout.
        /// </summary>
        /// <param name="context">the current context for the view.</param>
        private void Init(Context context, IAttributeSet attrs)
        {
            LayoutInflater inflater = context.GetSystemService(Context.LayoutInflaterService) as LayoutInflater;

            inflater.Inflate(Resource.Layout.MyEditTextView, this);

            #region Finding Views
            TitleTextView = FindViewById <TextView>(Resource.Id.myedittext_tv_title);
            ErrorTextView = FindViewById <TextView>(Resource.Id.myedittext_tv_error);
            InputEditText = FindViewById <EditText>(Resource.Id.myedittext_et_input);
            #endregion

            // Default values
            Error     = "";
            InputType = TextInputType.Text;

            if (attrs != null)
            {
                TypedArray typedArray = Context.ObtainStyledAttributes(attrs, Resource.Styleable.MyEditText);


                if (typedArray.HasValue(Resource.Styleable.MyEditText_title))
                {
                    Title = typedArray.GetString(Resource.Styleable.MyEditText_title);
                }

                if (typedArray.HasValue(Resource.Styleable.MyEditText_input))
                {
                    Input = typedArray.GetString(Resource.Styleable.MyEditText_input);
                }

                if (typedArray.HasValue(Resource.Styleable.MyEditText_inputHint))
                {
                    InputHint = typedArray.GetString(Resource.Styleable.MyEditText_inputHint);
                }

                if (typedArray.HasValue(Resource.Styleable.MyEditText_error))
                {
                    Error = typedArray.GetString(Resource.Styleable.MyEditText_error);
                }

                if (typedArray.HasValue(Resource.Styleable.MyEditText_inputType))
                {
                    InputType = (TextInputType)typedArray.GetInt(Resource.Styleable.MyEditText_inputType, (int)TextInputType.Text);
                }

                typedArray.Recycle();
            }
        }
        /// <summary>
        /// Reads any attributes that were assigned in XML and sets properties appropriately
        /// </summary>
        /// <param name="typedArray">The attributes to apply to the view</param>
        private void InitializeAttributes(TypedArray typedArray)
        {
            string attrFilename = typedArray.GetString(Resource.Styleable.XRayDisplayView_filename);

            Filename = attrFilename ?? ""; //if it is null it will be assigned an empty sting

            string attrDate = typedArray.GetString(Resource.Styleable.XRayDisplayView_date);

            Date = attrDate ?? "";

            string attrFilenameLabel = typedArray.GetString(Resource.Styleable.XRayDisplayView_filename_label);

            FilenameLabel = attrFilenameLabel ?? "";

            TextDisplayMode = (DisplayMode)typedArray.GetInt(Resource.Styleable.ConditionResultView_condition_displayMode, (int)DisplayMode.Small);
        }
Ejemplo n.º 10
0
        internal static string PullFontPathFromTheme(Context context, int styleAttrId, int[] attributeId)
        {
            if (styleAttrId == -1 || attributeId == null)
            {
                return(null);
            }

            Android.Content.Res.Resources.Theme theme = context.Theme;
            var value = new TypedValue();

            theme.ResolveAttribute(styleAttrId, value, true);
            TypedArray typedArray = theme.ObtainStyledAttributes(value.ResourceId, attributeId);

            try
            {
                string font = typedArray.GetString(0);
                return(font);
            }
            catch (Exception)
            {
                //failed for some reason
                return(null);
            }
            finally
            {
                typedArray.Recycle();
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Tries to pull the Font Path from the View Style as this is the next decendent after being
        /// defined in the View's xml.
        /// </summary>
        /// <returns>null if attribute is not defined or found in the Style</returns>
        /// <param name="context">Context.</param>
        /// <param name="attrs">View Attrs.</param>
        /// <param name="attributeId">if -1 returns null.</param>
        internal static string PullFontPathFromStyle(Context context, IAttributeSet attrs, int[] attributeId)
        {
            if (attributeId == null || attrs == null)
            {
                return(null);
            }

            TypedArray typedArray = context.ObtainStyledAttributes(attrs, attributeId);

            if (typedArray != null)
            {
                try
                {
                    // first defined attribute
                    string fontFromAttribute = typedArray.GetString(0);
                    if (!string.IsNullOrEmpty(fontFromAttribute))
                    {
                        return(fontFromAttribute);
                    }
                }
                catch (Exception)
                {
                    // failed for some reason
                }
                finally
                {
                    typedArray.Recycle();
                }
            }
            return(null);
        }
Ejemplo n.º 12
0
        private void Init(Context context = null, IAttributeSet attrs = null)
        {
            var backgroundSrc = Resource.Drawable.journey7;
            var thumbnailSrc  = Resource.Drawable.journey7;
            var title         = string.Empty;

            if (attrs != null && context != null)
            {
                TypedArray array = context.ObtainStyledAttributes(attrs, Resource.Styleable.PersonHeader);
                backgroundSrc = array.GetResourceId(Resource.Styleable.PersonHeader_backgroundSrc, backgroundSrc);
                thumbnailSrc  = array.GetResourceId(Resource.Styleable.PersonHeader_thumbnailSrc, thumbnailSrc);
                title         = array.GetString(Resource.Styleable.PersonHeader_title);
            }


            //////////////////////////////////////////////
            if (context != null)
            {
                Inflate(context, Resource.Layout.PersonHeader, this);
                _background = FindViewById <BlurredImage>(Resource.Id.PersonHeaderBackgorund);
                _thumbnail  = FindViewById <ImageView>(Resource.Id.PersonHeaderThumbnail);
                _title      = FindViewById <TextView>(Resource.Id.PersonHeaderTitle);

                _background.SetImageResource(backgroundSrc);
                _thumbnail.SetImageResource(thumbnailSrc);
                _thumbnail.ClipToOutline = true;
                _title.Text = title;
            }
        }
        protected override void UseStyleAttributes(TypedArray attrs)
        {
            var titleText       = attrs.GetString(Resource.Styleable.SingleLineIconWithTextView_textForTitle);
            var titleTextColor  = attrs.GetColor(Resource.Styleable.SingleLineIconWithTextView_textColorForTitle, -1);
            var titleTextSize   = attrs.GetDimension(Resource.Styleable.SingleLineIconWithTextView_textSizeForTitle, -1);
            var titleTextStyle  = attrs.GetInt(Resource.Styleable.SingleLineIconWithTextView_textStyleForTitle, (int)Enum.ToObject(typeof(TypefaceStyle), TypefaceStyle.Normal));
            var titleTypeface   = attrs.GetInt(Resource.Styleable.SingleLineIconWithTextView_typefaceForTitle, 0);
            var titleFontFamily = attrs.GetString(Resource.Styleable.SingleLineIconWithTextView_fontFamilyForTitle);
            var iconSrc         = attrs.GetDrawable(Resource.Styleable.SingleLineIconWithTextView_iconSrc);
            var iconTint        = attrs.GetColor(Resource.Styleable.SingleLineIconWithTextView_iconTint, -1);

            attrs.Recycle();

            PrepareTextViewWithAttrValues(viewTitle, titleText, titleTextColor, titleTextSize, titleTextStyle, titleTypeface, titleFontFamily);
            PrepareIconViewWithAttrValues(iconSrc, iconTint);
        }
Ejemplo n.º 14
0
        //applies font from XML
        public static void ApplyCustomFont(TextView view, Context context, IAttributeSet attrs)
        {
            TypedArray attributeArray = context.ObtainStyledAttributes(attrs, Resource.Styleable.CustomFont);

            string fontName  = attributeArray.GetString(Resource.Styleable.CustomFont_font);
            int    textStyle = attrs.GetAttributeIntValue(ANDROID_SCHEMA, "textStyle", 0);

            Typeface customFont = SelectTypeface(context, fontName);

            switch (textStyle)
            {
            case 1:
                view.SetTypeface(customFont, TypefaceStyle.Bold);
                break;

            case 2:
                view.SetTypeface(customFont, TypefaceStyle.Italic);
                break;

            case 3:
                view.SetTypeface(customFont, TypefaceStyle.BoldItalic);
                break;

            default:
                view.SetTypeface(customFont, TypefaceStyle.Normal);
                break;
            }

            attributeArray.Recycle();
        }
Ejemplo n.º 15
0
        private void Initialize(IAttributeSet attrs)
        {
            //Load those if set in xml resource file.
            TypedArray a = Context.ObtainStyledAttributes(attrs, Resource.Styleable.ColorPickerView);

            mShowAlphaPanel  = a.GetBoolean(Resource.Styleable.ColorPickerView_alphaChannelVisible, false);
            mAlphaSliderText = a.GetString(Resource.Styleable.ColorPickerView_alphaChannelText);
            //TODO : cross check calculation
            mSliderTrackerColor = a.GetColor(Resource.Styleable.ColorPickerView_colorPickerSliderColor, Int32.Parse("FFBDBDBD", System.Globalization.NumberStyles.HexNumber));
            mBorderColor        = a.GetColor(Resource.Styleable.ColorPickerView_colorPickerBorderColor, Int32.Parse("FF6E6E6E", System.Globalization.NumberStyles.HexNumber));
            a.Recycle();


            mDensity = Context.Resources.DisplayMetrics.Density;
            PALETTE_CIRCLE_TRACKER_RADIUS *= mDensity;
            RECTANGLE_TRACKER_OFFSET      *= mDensity;
            HUE_PANEL_WIDTH    *= mDensity;
            ALPHA_PANEL_HEIGHT *= mDensity;
            PANEL_SPACING       = PANEL_SPACING * mDensity;

            mDrawingOffset = calculateRequiredOffset();

            initPaintTools();

            //Needed for receiving trackball motion events.

            Focusable            = true;
            FocusableInTouchMode = true;
        }
Ejemplo n.º 16
0
        private static string ReadItemTemplateSelectorClassName(Context context, IAttributeSet attrs)
        {
            TypedArray typedArray = null;

            string className = string.Empty;

            try
            {
                typedArray = context.ObtainStyledAttributes(attrs, GroupId);
                int numberOfStyles = typedArray.IndexCount;

                for (int i = 0; i < numberOfStyles; ++i)
                {
                    var attributeId = typedArray.GetIndex(i);

                    if (attributeId == ItemTemplateSelector)
                    {
                        className = typedArray.GetString(attributeId);
                    }
                }
            }
            finally
            {
                typedArray?.Recycle();
            }

            return(className);
        }
        private void init(IAttributeSet attrs)
        {
            TypedArray a = Context.ObtainStyledAttributes(attrs, Resource.Styleable.ColorPickerPreference);

            showDialogTitle = a.GetBoolean(Resource.Styleable.ColorPickerPreference_showDialogTitle, false);
            showPreviewSelectedColorInList = a.GetBoolean(Resource.Styleable.ColorPickerPreference_showSelectedColorInList, true);

            a.Recycle();
            a = Context.ObtainStyledAttributes(attrs, Resource.Styleable.ColorPickerView);

            alphaChannelVisible    = a.GetBoolean(Resource.Styleable.ColorPickerView_alphaChannelVisible, false);
            alphaChannelText       = a.GetString(Resource.Styleable.ColorPickerView_alphaChannelText);
            colorPickerSliderColor = a.GetColor(Resource.Styleable.ColorPickerView_colorPickerSliderColor, -1);
            colorPickerBorderColor = a.GetColor(Resource.Styleable.ColorPickerView_colorPickerBorderColor, -1);

            a.Recycle();

            if (showPreviewSelectedColorInList)
            {
                WidgetLayoutResource = Resource.Layout.preference_preview_layout;
            }

            if (!showDialogTitle)
            {
                DialogTitle = null;
            }

            DialogLayoutResource = Resource.Layout.dialog_color_picker;


            SetPositiveButtonText(Resource.String.dialog_ok);
            SetNegativeButtonText(Resource.String.dialog_cancle);

            Persistent = true;
        }
Ejemplo n.º 18
0
        internal static List <string> ReadStringAttributeValue(Context context, IAttributeSet attrs, int[] groupId,
                                                               ICollection <int> requiredAttributeIds)
        {
            TypedArray typedArray = context.Theme.ObtainStyledAttributes(attrs, groupId, 0, 0);

            try
            {
                List <string> result = null;
                foreach (int attributeId in requiredAttributeIds)
                {
                    string s = typedArray.GetString(attributeId);
                    if (string.IsNullOrEmpty(s))
                    {
                        continue;
                    }
                    if (result == null)
                    {
                        result = new List <string>();
                    }
                    result.Add(s);
                }
                return(result);
            }
            finally
            {
                typedArray.Recycle();
            }
        }
Ejemplo n.º 19
0
        private void Init(Android.Content.Context context, IAttributeSet attrs)
        {
            TypedArray typedArray = context.ObtainStyledAttributes(attrs, Resource.Styleable.LoadingView);

            loadText = typedArray.GetString(Resource.Styleable.LoadingView_loadingText);
            typedArray.Recycle();
        }
Ejemplo n.º 20
0
        private void init(Context context, IAttributeSet attrs, int defStyleAttr, int defStyleRes)
        {
            mMinWidth  = 24;
            mMaxWidth  = 48;
            mMinHeight = 24;
            mMaxHeight = 48;

            TypedArray a = context.ObtainStyledAttributes(
                attrs, Resource.Styleable.AVLoadingIndicatorView, defStyleAttr, defStyleRes);


            mMinWidth  = a.GetDimensionPixelSize(Resource.Styleable.AVLoadingIndicatorView_minWidth, mMinWidth);
            mMaxWidth  = a.GetDimensionPixelSize(Resource.Styleable.AVLoadingIndicatorView_maxWidth, mMaxWidth);
            mMinHeight = a.GetDimensionPixelSize(Resource.Styleable.AVLoadingIndicatorView_minHeight, mMinHeight);
            mMaxHeight = a.GetDimensionPixelSize(Resource.Styleable.AVLoadingIndicatorView_maxHeight, mMaxHeight);
            string indicatorName = a.GetString(Resource.Styleable.AVLoadingIndicatorView_indicatorName);

            mIndicatorColor = a.GetColor(Resource.Styleable.AVLoadingIndicatorView_indicatorColor, Color.White);
            setIndicator(indicatorName);
            if (mIndicator == null)
            {
                setIndicator(DEFAULT_INDICATOR);
            }
            a.Recycle();
        }
Ejemplo n.º 21
0
        private static string ReadRecyclerViewItemTemplateSelectorClassName(Context context, IAttributeSet attrs)
        {
            TryInitializeBindingResourcePaths();

            TypedArray typedArray = null;

            string className = string.Empty;

            try
            {
                typedArray = context.ObtainStyledAttributes(attrs, MvxRecyclerViewItemTemplateSelectorGroupId);
                int numberOfStyles = typedArray.IndexCount;

                for (int i = 0; i < numberOfStyles; ++i)
                {
                    var attributeId = typedArray.GetIndex(i);

                    if (attributeId == MvxRecyclerViewItemTemplateSelector)
                    {
                        className = typedArray.GetString(attributeId);
                    }
                }
            }
            finally
            {
                typedArray?.Recycle();
            }

            if (string.IsNullOrEmpty(className))
            {
                return(typeof(MvxDefaultTemplateSelector).FullName);
            }

            return(className);
        }
        /// <summary>
        /// Initializes an object with values extracted from the argument attrs
        /// </summary>
        ///
        /// <Parameters>
        /// context: Interface to global information about an application environment
        /// attrs: A collection of attributes, as found associated with a tag in an XML document
        /// </Parameters>
        ///
        /// <Precondition>
        /// this constructor is supposed to be call by Android framework
        /// </Precondition>
        ///
        /// <Postcondition>
        /// an object is initialized with values extracted from the argument attrs
        /// </Postcondition>
        ///
        /// <Exceptions>
        /// ArgumentException - The parameter {0} is expected to be defined in XML or IAttributeSet but it is ommited
        /// </Exceptions>
        public GmailProfilePicture(Context context, IAttributeSet attrs) : base(context, attrs)
        {
            TypedArray typedArray = this.Context.ObtainStyledAttributes(attrs, Resource.Styleable.GmailProfilePicture);

            string exceptionMessageRequired    = "The parameter {0} is expected to be defined in XML or IAttributeSet but it is ommited";
            string exceptionMessageWrongFormat = "The parameter {0} does not have a correct format. The format’s type has to be {2}";

            int    tmpRadius      = 0;
            string tmpDisplayText = String.Empty;
            int    tmpTextSize    = 0;


            try
            {
                tmpRadius = typedArray.GetInteger(Resource.Styleable.GmailProfilePicture_radius, int.MinValue);
            }
            catch (Exception)
            {
                throw new ArgumentException(String.Format(exceptionMessageWrongFormat, "radius", "int"));
            }

            try
            {
                tmpDisplayText = typedArray.GetString(Resource.Styleable.GmailProfilePicture_display_text);
            }
            catch (Exception)
            {
                throw new ArgumentException(String.Format(exceptionMessageWrongFormat, "display_text", "string"));
            }

            try
            {
                tmpTextSize = typedArray.GetInteger(Resource.Styleable.GmailProfilePicture_text_size, int.MinValue);
            }
            catch (Exception)
            {
                throw new ArgumentException(String.Format(exceptionMessageWrongFormat, "text_size", "int"));
            }


            if (tmpRadius == int.MinValue)
            {
                throw new ArgumentException(String.Format(exceptionMessageRequired, "Radius"));
            }
            else if (tmpTextSize == int.MinValue)
            {
                throw new ArgumentException(String.Format(exceptionMessageRequired, "TextSize"));
            }
            else if (tmpDisplayText == null)
            {
                throw new ArgumentException(String.Format(exceptionMessageRequired, "DisplayText"));
            }

            this.displayText = tmpDisplayText;
            this.textSize    = tmpTextSize;
            this.radius      = tmpRadius;

            this.Init();
        }
Ejemplo n.º 23
0
        public PinWidget(Context context, IAttributeSet attribs, int defStyleAttr) : base(context, attribs, defStyleAttr)
        {
            ShouldRedraw      = false;
            this.FillViewport = true;
            ScrollBarStyle    = ScrollbarStyles.OutsideInset;

            TypedArray array = context.ObtainStyledAttributes(attribs, Resource.Styleable.PinView);

            var method = array.GetString(Resource.Styleable.PinView_onPinCompleted);

            PinListener = new PrivatePinListener(method, this);

            DigitCount = (uint)array.GetInt(Resource.Styleable.PinView_digitCount, PinDefaults.DIGIT_COUNT);

            DisplayMetrics metrics = Resources.DisplayMetrics;

            // Digit dimensions
            DigitWidth   = array.GetDimensionPixelSize(Resource.Styleable.PinView_digitWidth, (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, PinDefaults.DIGIT_WIDTH, metrics));
            DigitHeight  = array.GetDimensionPixelSize(Resource.Styleable.PinView_digitHeight, (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, PinDefaults.DIGIT_HEIGHT, metrics));
            DigitSpacing = array.GetDimensionPixelSize(Resource.Styleable.PinView_digitSpacing, (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, PinDefaults.DIGIT_SPACING, metrics));
            TextSize     = array.GetDimensionPixelSize(Resource.Styleable.PinView_textSize, (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, PinDefaults.TEXT_SIZE, metrics));

            TypedValue resolvedColor = new TypedValue();

            Resources.Theme theme = context.Theme;

            // Colors
            theme.ResolveAttribute(Android.Resource.Attribute.TextColorPrimary, resolvedColor, true);
            TextColor = array.GetColor(Resource.Styleable.PinView_textColor,
                                       resolvedColor.ResourceId > 0 ? ContextCompat.GetColor(context, resolvedColor.ResourceId) : resolvedColor.Data);

            DigitBorderColor = array.GetColor(Resource.Styleable.PinView_borderColor, TextColor);

            resolvedColor = new TypedValue();
            theme.ResolveAttribute(Android.Resource.Attribute.ColorAccent, resolvedColor, true);
            AccentColor = array.GetColor(Resource.Styleable.PinView_accentColor,
                                         resolvedColor.ResourceId > 0 ? ContextCompat.GetColor(context, resolvedColor.ResourceId) : resolvedColor.Data);

            resolvedColor = new TypedValue();
            theme.ResolveAttribute(Android.Resource.Attribute.WindowBackground, resolvedColor, true);
            DigitBackgroundColor = array.GetColor(Resource.Styleable.PinView_digitBackgroundColor,
                                                  resolvedColor.ResourceId > 0 ? ContextCompat.GetColor(context, resolvedColor.ResourceId) : resolvedColor.Data);

            AccentHeight = (int)array.GetDimension(Resource.Styleable.PinView_accentHeight, TypedValue.ApplyDimension(ComplexUnitType.Dip, PinDefaults.ACCENT_HEIGHT, metrics));

            array.Recycle();

            _mainLayout    = new LinearLayout(Context);
            _pinInputField = new EditText(Context);

            var container = new FrameLayout(Context);

            container.AddView(_mainLayout);
            container.AddView(_pinInputField);
            this.AddView(container);

            ShouldRedraw = true;
        }
Ejemplo n.º 24
0
        public BoundImageView(Context context, IAttributeSet attrs) : base(context, attrs)
        {
            _context = context;
            ViewBinding.FillBoundView(this, context, attrs);

            TypedArray attrArr2 = _context.ObtainStyledAttributes(attrs, Resource.Styleable.BoundButton);

            ClickBinding = attrArr2.GetString(Resource.Styleable.BoundButton_onclick);
        }
Ejemplo n.º 25
0
        static string GetStringValueFromAttribute(this Context context, IAttributeSet attrs, int[] controlAttr, int attr)
        {
            TypedArray styledAttrs = context.ObtainStyledAttributes(attrs, controlAttr);
            string     value       = styledAttrs.GetString(attr);

            styledAttrs.Recycle();

            return(value);
        }
Ejemplo n.º 26
0
        private void Init(Context context, IAttributeSet attrs)
        {
            TypedArray ta = context.ObtainStyledAttributes(attrs, Resource.Styleable.TriangleLabelView);

            this.topPadding    = ta.GetDimension(Resource.Styleable.TriangleLabelView_labelTopPadding, 7f.DpToPx(this.Context));
            this.centerPadding = ta.GetDimension(Resource.Styleable.TriangleLabelView_labelCenterPadding, 3f.DpToPx(this.Context));
            this.bottomPadding = ta.GetDimension(Resource.Styleable.TriangleLabelView_labelBottomPadding, 3f.DpToPx(this.Context));

            this.triangleBackgroundColor = ta.GetColor(Resource.Styleable.TriangleLabelView_backgroundColor, Color.ParseColor("#66000000"));
            this.primary.Color           = ta.GetColor(Resource.Styleable.TriangleLabelView_primaryTextColor, Color.White);
            this.secondary.Color         = ta.GetColor(Resource.Styleable.TriangleLabelView_secondaryTextColor, Color.White);

            this.primary.Size   = ta.GetDimension(Resource.Styleable.TriangleLabelView_primaryTextSize, 11f.SpToPx(this.Context));
            this.secondary.Size = ta.GetDimension(Resource.Styleable.TriangleLabelView_secondaryTextSize, 8f.SpToPx(this.Context));

            var primaryText = ta.GetString(Resource.Styleable.TriangleLabelView_primaryText);

            if (!string.IsNullOrEmpty(primaryText))
            {
                this.primary.Text = primaryText;
            }
            var secondaryText = ta.GetString(Resource.Styleable.TriangleLabelView_secondaryText);

            if (!string.IsNullOrEmpty(secondaryText))
            {
                this.secondary.Text = secondaryText;
            }

            this.primary.Style   = ta.GetInt(Resource.Styleable.TriangleLabelView_primaryTextStyle, 2);
            this.secondary.Style = ta.GetInt(Resource.Styleable.TriangleLabelView_secondaryTextStyle, 0);

            this.Corner = (Corner)ta.GetInt(Resource.Styleable.TriangleLabelView_corner, 1);

            ta.Recycle();

            this.primary.Initialize();
            this.secondary.Initialize();

            this.trianglePaint       = new Paint(PaintFlags.AntiAlias);
            this.trianglePaint.Color = this.triangleBackgroundColor;

            this.primary.ResetStatus();
            this.secondary.ResetStatus();
        }
        private void InitAttributes(IAttributeSet attrs)
        {
            TypedArray styleable = Context.ObtainStyledAttributes(attrs, Resource.Styleable.FloatingTextButton, 0, 0);

            text       = styleable.GetString(Resource.Styleable.FloatingTextButton_floating_title);
            textColor  = styleable.GetColor(Resource.Styleable.FloatingTextButton_floating_title_color, Color.Black);
            leftIcon   = styleable.GetDrawable(Resource.Styleable.FloatingTextButton_floating_left_icon);
            background = styleable.GetColor(Resource.Styleable.FloatingTextButton_floating_background_color, Color.White);
            styleable.Recycle();
        }
Ejemplo n.º 28
0
        public CoreTextView(Context context, IAttributeSet attrs, int defStyle)
            : base(context, attrs, defStyle)
        {
            TypedArray array = context.ObtainStyledAttributes(attrs, Resource.Styleable.CustomFont, defStyle, 0);

            this.CustomFontPath = array.GetString(Resource.Styleable.CustomFont_customFont);
            array.Recycle();

            SetCustomFont(this.CustomFontPath);
        }
Ejemplo n.º 29
0
        static string GetFontNameFromTypefaceAttribute(this Context context, IAttributeSet attrs, int[] controlAttr,
                                                       int attr)
        {
            TypedArray styledAttrs = context.ObtainStyledAttributes(attrs, controlAttr);
            string     fontName    = styledAttrs.GetString(attr);

            styledAttrs.Recycle();

            return(AddPathToFontName(fontName));
        }
Ejemplo n.º 30
0
        private void GetAttributesFromXmlAndStoreLocally()
        {
            TypedArray AttributesFromXmlLayout = Context.ObtainStyledAttributes(Attrs, Resource.Styleable.FloatLabelEditText);

            if (AttributesFromXmlLayout == null)
            {
                return;
            }

            HintText        = AttributesFromXmlLayout.GetString(Resource.Styleable.FloatLabelEditText_hint);
            EditText        = AttributesFromXmlLayout.GetString(Resource.Styleable.FloatLabelEditText_text);
            _gravity        = AttributesFromXmlLayout.GetInt(Resource.Styleable.FloatLabelEditText_gravity, (int)GravityFlags.Left);
            TextSizeInSp    = GetScaledFontSize(AttributesFromXmlLayout.GetDimensionPixelSize(Resource.Styleable.FloatLabelEditText_textSize, (int)_editTextView.TextSize));
            _focusedColor   = AttributesFromXmlLayout.GetColor(Resource.Styleable.FloatLabelEditText_textColorHintFocused, Android.Resource.Color.Black);
            UnFocusedColor  = AttributesFromXmlLayout.GetColor(Resource.Styleable.FloatLabelEditText_textColorHintUnFocused, Android.Resource.Color.DarkerGray);
            _fitScreenWidth = AttributesFromXmlLayout.GetInt(Resource.Styleable.FloatLabelEditText_fitScreenWidth, 0);
            _isPassword     = (AttributesFromXmlLayout.GetInt(Resource.Styleable.FloatLabelEditText_inputType, 0) == 1);
            AttributesFromXmlLayout.Recycle();
        }
 private void ApplyBindingsFromAttribute(View view, TypedArray typedArray, int attributeId)
 {
     try
     {
         var bindingText = typedArray.GetString(attributeId);
         var newBindings = Binder.Bind(_source, view, bindingText);
         StoreBindings(view, newBindings);
     }
     catch (Exception exception)
     {
         MvxBindingTrace.Trace(MvxTraceLevel.Error, "Exception thrown during the view binding {0}",
                               exception.ToLongString());
     }
 }
 private void ApplyLanguageBindingsFromAttribute(View view, TypedArray typedArray, int attributeId)
 {
     try
     {
         var bindingText = typedArray.GetString(attributeId);
         var newBindings = Binder.LanguageBind(_source, view, bindingText);
         if (newBindings != null)
         {
             _viewBindings.AddRange(newBindings);
         }
     }
     catch (Exception exception)
     {
         MvxBindingTrace.Trace(MvxTraceLevel.Error, "Exception thrown during the view language binding {0}",
                               exception.ToLongString());
         throw;
     }
 }