Skip to content

Commit

Permalink
Fix: Duplicate "attr" name issues when using multiple Android libraries.
Browse files Browse the repository at this point in the history
  • Loading branch information
2dxgujun committed May 23, 2015
1 parent 8d664c2 commit 7be6c44
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 83 deletions.
2 changes: 1 addition & 1 deletion demo/src/main/res/layout/activity_tag_editor.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
<me.gujun.android.taggroup.TagGroup
android:id="@+id/tag_group"
style="@style/TagGroup"
app:isAppendMode="true"/>
app:atg_isAppendMode="true"/>
</LinearLayout>
38 changes: 19 additions & 19 deletions library/src/main/java/me/gujun/android/taggroup/TagGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,25 +154,25 @@ public TagGroup(Context context, AttributeSet attrs, int defStyleAttr) {
// Load styled attributes.
final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TagGroup, defStyleAttr, R.style.TagGroup);
try {
isAppendMode = a.getBoolean(R.styleable.TagGroup_isAppendMode, false);
inputHint = a.getText(R.styleable.TagGroup_inputHint);
borderColor = a.getColor(R.styleable.TagGroup_borderColor, default_border_color);
textColor = a.getColor(R.styleable.TagGroup_textColor, default_text_color);
backgroundColor = a.getColor(R.styleable.TagGroup_backgroundColor, default_background_color);
dashBorderColor = a.getColor(R.styleable.TagGroup_dashBorderColor, default_dash_border_color);
inputHintColor = a.getColor(R.styleable.TagGroup_inputHintColor, default_input_hint_color);
inputTextColor = a.getColor(R.styleable.TagGroup_inputTextColor, default_input_text_color);
checkedBorderColor = a.getColor(R.styleable.TagGroup_checkedBorderColor, default_checked_border_color);
checkedTextColor = a.getColor(R.styleable.TagGroup_checkedTextColor, default_checked_text_color);
checkedMarkerColor = a.getColor(R.styleable.TagGroup_checkedMarkerColor, default_checked_marker_color);
checkedBackgroundColor = a.getColor(R.styleable.TagGroup_checkedBackgroundColor, default_checked_background_color);
pressedBackgroundColor = a.getColor(R.styleable.TagGroup_pressedBackgroundColor, default_pressed_background_color);
borderStrokeWidth = a.getDimension(R.styleable.TagGroup_borderStrokeWidth, default_border_stroke_width);
textSize = a.getDimension(R.styleable.TagGroup_textSize, default_text_size);
horizontalSpacing = (int) a.getDimension(R.styleable.TagGroup_horizontalSpacing, default_horizontal_spacing);
verticalSpacing = (int) a.getDimension(R.styleable.TagGroup_verticalSpacing, default_vertical_spacing);
horizontalPadding = (int) a.getDimension(R.styleable.TagGroup_horizontalPadding, default_horizontal_padding);
verticalPadding = (int) a.getDimension(R.styleable.TagGroup_verticalPadding, default_vertical_padding);
isAppendMode = a.getBoolean(R.styleable.TagGroup_atg_isAppendMode, false);
inputHint = a.getText(R.styleable.TagGroup_atg_inputHint);
borderColor = a.getColor(R.styleable.TagGroup_atg_borderColor, default_border_color);
textColor = a.getColor(R.styleable.TagGroup_atg_textColor, default_text_color);
backgroundColor = a.getColor(R.styleable.TagGroup_atg_backgroundColor, default_background_color);
dashBorderColor = a.getColor(R.styleable.TagGroup_atg_dashBorderColor, default_dash_border_color);
inputHintColor = a.getColor(R.styleable.TagGroup_atg_inputHintColor, default_input_hint_color);
inputTextColor = a.getColor(R.styleable.TagGroup_atg_inputTextColor, default_input_text_color);
checkedBorderColor = a.getColor(R.styleable.TagGroup_atg_checkedBorderColor, default_checked_border_color);
checkedTextColor = a.getColor(R.styleable.TagGroup_atg_checkedTextColor, default_checked_text_color);
checkedMarkerColor = a.getColor(R.styleable.TagGroup_atg_checkedMarkerColor, default_checked_marker_color);
checkedBackgroundColor = a.getColor(R.styleable.TagGroup_atg_checkedBackgroundColor, default_checked_background_color);
pressedBackgroundColor = a.getColor(R.styleable.TagGroup_atg_pressedBackgroundColor, default_pressed_background_color);
borderStrokeWidth = a.getDimension(R.styleable.TagGroup_atg_borderStrokeWidth, default_border_stroke_width);
textSize = a.getDimension(R.styleable.TagGroup_atg_textSize, default_text_size);
horizontalSpacing = (int) a.getDimension(R.styleable.TagGroup_atg_horizontalSpacing, default_horizontal_spacing);
verticalSpacing = (int) a.getDimension(R.styleable.TagGroup_atg_verticalSpacing, default_vertical_spacing);
horizontalPadding = (int) a.getDimension(R.styleable.TagGroup_atg_horizontalPadding, default_horizontal_padding);
verticalPadding = (int) a.getDimension(R.styleable.TagGroup_atg_verticalPadding, default_vertical_padding);
} finally {
a.recycle();
}
Expand Down
38 changes: 19 additions & 19 deletions library/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
<resources>
<declare-styleable name="TagGroup">
<!-- Whether the tag group is in append mode. -->
<attr name="isAppendMode" format="boolean" />
<attr name="atg_isAppendMode" format="boolean" />
<!-- If the tag group is in append mode, what the hint of input tag. -->
<attr name="inputHint" format="string" />
<attr name="atg_inputHint" format="string" />

<!-- The tag view outline border color. -->
<attr name="borderColor" format="color" />
<attr name="atg_borderColor" format="color" />
<!-- The tag view text color. -->
<attr name="textColor" format="color" />
<attr name="atg_textColor" format="color" />
<!-- The tag view background color. -->
<attr name="backgroundColor" format="color" />
<attr name="atg_backgroundColor" format="color" />

<!-- The dash outline border color, when in append mode. -->
<attr name="dashBorderColor" format="color" />
<attr name="atg_dashBorderColor" format="color" />
<!-- The input tag hint text color, when in append mode. -->
<attr name="inputHintColor" format="color" />
<attr name="atg_inputHintColor" format="color" />
<!-- The input tag type text color, when in append mode. -->
<attr name="inputTextColor" format="color" />
<attr name="atg_inputTextColor" format="color" />

<!-- The checked tag view outline border color. -->
<attr name="checkedBorderColor" format="color" />
<attr name="atg_checkedBorderColor" format="color" />
<!-- The checked text color. -->
<attr name="checkedTextColor" format="color" />
<attr name="atg_checkedTextColor" format="color" />
<!-- The checked marker color. -->
<attr name="checkedMarkerColor" format="color" />
<attr name="atg_checkedMarkerColor" format="color" />
<!-- The checked tag view background color. -->
<attr name="checkedBackgroundColor" format="color" />
<attr name="atg_checkedBackgroundColor" format="color" />

<!-- The tag view background color, when the tag view is being pressed. -->
<attr name="pressedBackgroundColor" format="color" />
<attr name="atg_pressedBackgroundColor" format="color" />

<!-- The tag view outline border stroke width. -->
<attr name="borderStrokeWidth" format="dimension" />
<attr name="atg_borderStrokeWidth" format="dimension" />
<!-- The tag view text size. -->
<attr name="textSize" format="dimension" />
<attr name="atg_textSize" format="dimension" />

<attr name="horizontalSpacing" format="dimension" />
<attr name="verticalSpacing" format="dimension" />
<attr name="horizontalPadding" format="dimension" />
<attr name="verticalPadding" format="dimension" />
<attr name="atg_horizontalSpacing" format="dimension" />
<attr name="atg_verticalSpacing" format="dimension" />
<attr name="atg_horizontalPadding" format="dimension" />
<attr name="atg_verticalPadding" format="dimension" />
</declare-styleable>

<declare-styleable name="Themes">
Expand Down
88 changes: 44 additions & 44 deletions library/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,61 +4,61 @@
<style name="TagGroup">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="isAppendMode">false</item>
<item name="inputHint">@string/add_tag</item>
<item name="borderColor">#49C120</item>
<item name="textColor">#49C120</item>
<item name="backgroundColor">#FFFFFF</item>
<item name="dashBorderColor">#AAAAAA</item>
<item name="inputHintColor">#80000000</item>
<item name="inputTextColor">#DE000000</item>
<item name="checkedBorderColor">#49C120</item>
<item name="checkedTextColor">#FFFFFF</item>
<item name="checkedMarkerColor">#FFFFFF</item>
<item name="checkedBackgroundColor">#49C120</item>
<item name="pressedBackgroundColor">#EDEDED</item>
<item name="borderStrokeWidth">0.5dp</item>
<item name="textSize">13sp</item>
<item name="horizontalSpacing">8dp</item>
<item name="verticalSpacing">4dp</item>
<item name="horizontalPadding">12dp</item>
<item name="verticalPadding">3dp</item>
<item name="atg_isAppendMode">false</item>
<item name="atg_inputHint">@string/add_tag</item>
<item name="atg_borderColor">#49C120</item>
<item name="atg_textColor">#49C120</item>
<item name="atg_backgroundColor">#FFFFFF</item>
<item name="atg_dashBorderColor">#AAAAAA</item>
<item name="atg_inputHintColor">#80000000</item>
<item name="atg_inputTextColor">#DE000000</item>
<item name="atg_checkedBorderColor">#49C120</item>
<item name="atg_checkedTextColor">#FFFFFF</item>
<item name="atg_checkedMarkerColor">#FFFFFF</item>
<item name="atg_checkedBackgroundColor">#49C120</item>
<item name="atg_pressedBackgroundColor">#EDEDED</item>
<item name="atg_borderStrokeWidth">0.5dp</item>
<item name="atg_textSize">13sp</item>
<item name="atg_horizontalSpacing">8dp</item>
<item name="atg_verticalSpacing">4dp</item>
<item name="atg_horizontalPadding">12dp</item>
<item name="atg_verticalPadding">3dp</item>
</style>

<style name="TagGroup.Small" parent="TagGroup">
<item name="textSize">10sp</item>
<item name="horizontalSpacing">6dp</item>
<item name="verticalSpacing">3dp</item>
<item name="horizontalPadding">8dp</item>
<item name="verticalPadding">2dp</item>
<item name="atg_textSize">10sp</item>
<item name="atg_horizontalSpacing">6dp</item>
<item name="atg_verticalSpacing">3dp</item>
<item name="atg_horizontalPadding">8dp</item>
<item name="atg_verticalPadding">2dp</item>
</style>

<style name="TagGroup.Large" parent="TagGroup">
<item name="borderStrokeWidth">0.7dp</item>
<item name="textSize">15sp</item>
<item name="horizontalSpacing">9dp</item>
<item name="verticalSpacing">5dp</item>
<item name="horizontalPadding">14dp</item>
<item name="verticalPadding">4dp</item>
<item name="atg_borderStrokeWidth">0.7dp</item>
<item name="atg_textSize">15sp</item>
<item name="atg_horizontalSpacing">9dp</item>
<item name="atg_verticalSpacing">5dp</item>
<item name="atg_horizontalPadding">14dp</item>
<item name="atg_verticalPadding">4dp</item>
</style>

<style name="TagGroup.Beauty_Red" parent="TagGroup">
<item name="borderColor">#FF3D7F</item>
<item name="textColor">#FF3D7F</item>
<item name="checkedBorderColor">#FF3D7F</item>
<item name="checkedBackgroundColor">#FF3D7F</item>
<item name="atg_borderColor">#FF3D7F</item>
<item name="atg_textColor">#FF3D7F</item>
<item name="atg_checkedBorderColor">#FF3D7F</item>
<item name="atg_checkedBackgroundColor">#FF3D7F</item>
</style>

<style name="TagGroup.Beauty_Red.Inverse" parent="TagGroup">
<item name="borderColor">#FF3D7F</item>
<item name="textColor">#FFFFFF</item>
<item name="backgroundColor">#FF3D7F</item>
<item name="inputHintColor">#80FFFFFF</item>
<item name="inputTextColor">#DEFFFFFF</item>
<item name="checkedBorderColor">#FF3D7F</item>
<item name="checkedTextColor">#FF3D7F</item>
<item name="checkedMarkerColor">#FF3D7F</item>
<item name="checkedBackgroundColor">#FFFFFF</item>
<item name="pressedBackgroundColor">#FF99B1</item>
<item name="atg_borderColor">#FF3D7F</item>
<item name="atg_textColor">#FFFFFF</item>
<item name="atg_backgroundColor">#FF3D7F</item>
<item name="atg_inputHintColor">#80FFFFFF</item>
<item name="atg_inputTextColor">#DEFFFFFF</item>
<item name="atg_checkedBorderColor">#FF3D7F</item>
<item name="atg_checkedTextColor">#FF3D7F</item>
<item name="atg_checkedMarkerColor">#FF3D7F</item>
<item name="atg_checkedBackgroundColor">#FFFFFF</item>
<item name="atg_pressedBackgroundColor">#FF99B1</item>
</style>
</resources>

0 comments on commit 7be6c44

Please sign in to comment.