예제 #1
0
        private void Init(Context context, IAttributeSet attrs)
        {
            Init(context);
            MessageInputStyle style = MessageInputStyle.Parse(context, attrs);

            this.messageInput.SetMaxLines(style.getInputMaxLines());
            this.messageInput.Hint = style.getInputHint();
            this.messageInput.Text = style.getInputText();
            this.messageInput.SetTextSize(ComplexUnitType.Px, style.getInputTextSize());
            this.messageInput.SetTextColor(new ColorStateList(new int[][] { new int[] { 0 } }, new int[] { style.getInputTextColor() }));
            this.messageInput.SetHintTextColor(new ColorStateList(new int[][] { new int[] { 0 } }, new int[] { style.getInputHintColor() }));
            this.messageInput.Background = style.getInputBackground();
            SetCursor(style.getInputCursorDrawable());

            this.attachmentButton.Visibility = style.showAttachmentButton() ? ViewStates.Visible : ViewStates.Gone;
            this.attachmentButton.Background = style.getAttachmentButtonBackground();
            this.attachmentButton.SetImageDrawable(style.getAttachmentButtonIcon());
            this.attachmentButton.LayoutParameters.Width  = style.getAttachmentButtonWidth();
            this.attachmentButton.LayoutParameters.Height = style.getAttachmentButtonHeight();

            this.attachmentButtonSpace.Visibility             = style.showAttachmentButton() ? ViewStates.Visible : ViewStates.Gone;
            this.attachmentButtonSpace.LayoutParameters.Width = style.getAttachmentButtonMargin();

            this.messageSendButton.Background = style.getInputButtonBackground();
            this.messageSendButton.SetImageDrawable(style.getInputButtonIcon());
            this.messageSendButton.LayoutParameters.Width  = style.getInputButtonWidth();
            this.messageSendButton.LayoutParameters.Height = style.getInputButtonHeight();
            this.sendButtonSpace.LayoutParameters.Width    = style.getInputButtonMargin();

            if (PaddingLeft == 0 &&
                PaddingRight == 0 &&
                PaddingTop == 0 &&
                PaddingBottom == 0)
            {
                SetPadding(
                    style.getInputDefaultPaddingLeft(),
                    style.getInputDefaultPaddingTop(),
                    style.getInputDefaultPaddingRight(),
                    style.getInputDefaultPaddingBottom()
                    );
            }
        }
        public static MessageInputStyle Parse(Context context, IAttributeSet attrs)
        {
            MessageInputStyle style      = new MessageInputStyle(context, attrs);
            TypedArray        typedArray = context.ObtainStyledAttributes(attrs, Resource.Styleable.MessageInput);

            style._showAttachmentButton = typedArray.GetBoolean(Resource.Styleable.MessageInput_showAttachmentButton, false);

            style.attachmentButtonBackground     = typedArray.GetResourceId(Resource.Styleable.MessageInput_attachmentButtonBackground, -1);
            style.attachmentButtonDefaultBgColor = typedArray.GetColor(Resource.Styleable.MessageInput_attachmentButtonDefaultBgColor,
                                                                       style.GetColor(Resource.Color.white_four));
            style.attachmentButtonDefaultBgPressedColor = typedArray.GetColor(Resource.Styleable.MessageInput_attachmentButtonDefaultBgPressedColor,
                                                                              style.GetColor(Resource.Color.white_five));
            style.attachmentButtonDefaultBgDisabledColor = typedArray.GetColor(Resource.Styleable.MessageInput_attachmentButtonDefaultBgDisabledColor,
                                                                               style.GetColor(Resource.Color.transparent));

            style.attachmentButtonIcon             = typedArray.GetResourceId(Resource.Styleable.MessageInput_attachmentButtonIcon, -1);
            style.attachmentButtonDefaultIconColor = typedArray.GetColor(Resource.Styleable.MessageInput_attachmentButtonDefaultIconColor,
                                                                         style.GetColor(Resource.Color.cornflower_blue_two));
            style.attachmentButtonDefaultIconPressedColor = typedArray.GetColor(Resource.Styleable.MessageInput_attachmentButtonDefaultIconPressedColor,
                                                                                style.GetColor(Resource.Color.cornflower_blue_two_dark));
            style.attachmentButtonDefaultIconDisabledColor = typedArray.GetColor(Resource.Styleable.MessageInput_attachmentButtonDefaultIconDisabledColor,
                                                                                 style.GetColor(Resource.Color.cornflower_blue_light_40));

            style.attachmentButtonWidth  = typedArray.GetDimensionPixelSize(Resource.Styleable.MessageInput_attachmentButtonWidth, style.GetDimension(Resource.Dimension.input_button_width));
            style.attachmentButtonHeight = typedArray.GetDimensionPixelSize(Resource.Styleable.MessageInput_attachmentButtonHeight, style.GetDimension(Resource.Dimension.input_button_height));
            style.attachmentButtonMargin = typedArray.GetDimensionPixelSize(Resource.Styleable.MessageInput_attachmentButtonMargin, style.GetDimension(Resource.Dimension.input_button_margin));

            style.inputButtonBackground     = typedArray.GetResourceId(Resource.Styleable.MessageInput_inputButtonBackground, -1);
            style.inputButtonDefaultBgColor = typedArray.GetColor(Resource.Styleable.MessageInput_inputButtonDefaultBgColor,
                                                                  style.GetColor(Resource.Color.cornflower_blue_two));
            style.inputButtonDefaultBgPressedColor = typedArray.GetColor(Resource.Styleable.MessageInput_inputButtonDefaultBgPressedColor,
                                                                         style.GetColor(Resource.Color.cornflower_blue_two_dark));
            style.inputButtonDefaultBgDisabledColor = typedArray.GetColor(Resource.Styleable.MessageInput_inputButtonDefaultBgDisabledColor,
                                                                          style.GetColor(Resource.Color.white_four));

            style.inputButtonIcon             = typedArray.GetResourceId(Resource.Styleable.MessageInput_inputButtonIcon, -1);
            style.inputButtonDefaultIconColor = typedArray.GetColor(Resource.Styleable.MessageInput_inputButtonDefaultIconColor,
                                                                    style.GetColor(Resource.Color.white));
            style.inputButtonDefaultIconPressedColor = typedArray.GetColor(Resource.Styleable.MessageInput_inputButtonDefaultIconPressedColor,
                                                                           style.GetColor(Resource.Color.white));
            style.inputButtonDefaultIconDisabledColor = typedArray.GetColor(Resource.Styleable.MessageInput_inputButtonDefaultIconDisabledColor,
                                                                            style.GetColor(Resource.Color.warm_grey));

            style.inputButtonWidth  = typedArray.GetDimensionPixelSize(Resource.Styleable.MessageInput_inputButtonWidth, style.GetDimension(Resource.Dimension.input_button_width));
            style.inputButtonHeight = typedArray.GetDimensionPixelSize(Resource.Styleable.MessageInput_inputButtonHeight, style.GetDimension(Resource.Dimension.input_button_height));
            style.inputButtonMargin = typedArray.GetDimensionPixelSize(Resource.Styleable.MessageInput_inputButtonMargin, style.GetDimension(Resource.Dimension.input_button_margin));

            style.inputMaxLines = typedArray.GetInt(Resource.Styleable.MessageInput_inputMaxLines, DEFAULT_MAX_LINES);
            style.inputHint     = typedArray.GetString(Resource.Styleable.MessageInput_inputHint);
            style.inputText     = typedArray.GetString(Resource.Styleable.MessageInput_inputText);

            style.inputTextSize  = typedArray.GetDimensionPixelSize(Resource.Styleable.MessageInput_inputTextSize, style.GetDimension(Resource.Dimension.input_text_size));
            style.inputTextColor = typedArray.GetColor(Resource.Styleable.MessageInput_inputTextColor, style.GetColor(Resource.Color.dark_grey_two));
            style.inputHintColor = typedArray.GetColor(Resource.Styleable.MessageInput_inputHintColor, style.GetColor(Resource.Color.warm_grey_three));

            style.inputBackground     = typedArray.GetDrawable(Resource.Styleable.MessageInput_inputBackground);
            style.inputCursorDrawable = typedArray.GetDrawable(Resource.Styleable.MessageInput_inputCursorDrawable);

            typedArray.Recycle();

            style.inputDefaultPaddingLeft   = style.GetDimension(Resource.Dimension.input_padding_left);
            style.inputDefaultPaddingRight  = style.GetDimension(Resource.Dimension.input_padding_right);
            style.inputDefaultPaddingTop    = style.GetDimension(Resource.Dimension.input_padding_top);
            style.inputDefaultPaddingBottom = style.GetDimension(Resource.Dimension.input_padding_bottom);

            return(style);
        }