Skip to content

Commit

Permalink
added 'cmv_' prefix to attributes to solve issue #2
Browse files Browse the repository at this point in the history
  • Loading branch information
himanshu-soni committed Sep 10, 2015
1 parent 408d70d commit c0b18e0
Show file tree
Hide file tree
Showing 10 changed files with 72 additions and 74 deletions.
40 changes: 20 additions & 20 deletions README.md
Expand Up @@ -18,7 +18,7 @@ add gradle dependency to your dependency list:

``` groovy
dependencies {
compile 'me.himanshusoni.chatmessageview:chat-message-view:1.0.1'
compile 'me.himanshusoni.chatmessageview:chat-message-view:1.0.2'
}
```

Expand All @@ -30,9 +30,9 @@ dependencies {
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:backgroundColor="#88BABABA"
app:backgroundColorPressed="#FFBABABA"
app:cornerRadius="3dp" >
app:cmv_backgroundColor="#88BABABA"
app:cmv_backgroundColorPressed="#FFBABABA"
app:cmv_cornerRadius="3dp" >

<TextView
android:id="@+id/text"
Expand All @@ -50,27 +50,27 @@ dependencies {
Attributes:

``` xml
app:arrowGravity="start|end|center"
app:arrowPosition="right|left|top|bottom"
app:arrowMargin="3dp"
app:contentPadding="10dp"
app:backgroundColor="#88BABABA"
app:backgroundColorPressed="#FFBABABA"
app:cornerRadius="3dp"
app:showArrow="true"
app:cmv_arrowGravity="start|end|center"
app:cmv_arrowPosition="right|left|top|bottom"
app:cmv_arrowMargin="3dp"
app:cmv_contentPadding="10dp"
app:cmv_backgroundColor="#88BABABA"
app:cmv_backgroundColorPressed="#FFBABABA"
app:cmv_cornerRadius="3dp"
app:cmv_showArrow="true|false"
```

Description:


- `arrowGravity` controls relative position of arrow. possible values are `start`,`end` and `center`. default is `left`.
- `arrowPosition` controls poition of the arrow outside the box. possible values are `right`,`left`,`top` and `bottom`. default is `left`.
- `arrowMargin` controls margin of arrow. If `arrowPosition` is `left` or `right` it controls top and bottom margin. else it controls left and right margin.
- `contentPadding` adjusts padding of content within the box.
- `backgroundColor` sets background color of `ChatMessageView` in normal mode including arrow.
- `backgroundColorPressed` sets background color of `ChatMessageView` in pressed mode including arrow.
- `cornerRadius` sets corner radius of the box.
- `showArrow` shows / hides arrow from `ChatMessageView`.
- `cmv_arrowGravity` controls relative position of arrow. possible values are `start`,`end` and `center`. default is `left`.
- `cmv_arrowPosition` controls poition of the arrow outside the box. possible values are `right`,`left`,`top` and `bottom`. default is `left`.
- `cmv_arrowMargin` controls margin of arrow. If `cmv_arrowPosition` is `left` or `right` it controls top and bottom margin. else it controls left and right margin.
- `cmv_contentPadding` adjusts padding of content within the box.
- `cmv_backgroundColor` sets background color of `ChatMessageView` in normal mode including arrow.
- `cmv_backgroundColorPressed` sets background color of `ChatMessageView` in pressed mode including arrow.
- `cmv_cornerRadius` sets corner radius of the box.
- `cmv_showArrow` shows / hides arrow from `ChatMessageView`.



Expand Down
2 changes: 1 addition & 1 deletion chat-message-view/build.gradle
Expand Up @@ -29,7 +29,7 @@ ext {
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
resourcePrefix "cmv_"
// resourcePrefix "cmv_"

defaultConfig {
minSdkVersion 15
Expand Down
Expand Up @@ -18,7 +18,7 @@
import me.himanshusoni.chatmessageview.util.ViewUtil;

/**
* Created by himanshusoni on 06/09/15.
* Chat Message view to create chatting window view
*/
public class ChatMessageView extends RelativeLayout {
private ImageView arrowImage;
Expand Down Expand Up @@ -50,17 +50,17 @@ public ChatMessageView(Context context, AttributeSet attrs, int defStyleAttr) {
private void initialize(AttributeSet attrs, int defStyleAttr) {
TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.ChatMessageView, defStyleAttr, 0);

showArrow = a.getBoolean(R.styleable.ChatMessageView_showArrow, true);
arrowMargin = a.getDimension(R.styleable.ChatMessageView_arrowMargin, dip2px(5));
cornerRadius = a.getDimension(R.styleable.ChatMessageView_cornerRadius, 0);
contentPadding = a.getDimension(R.styleable.ChatMessageView_contentPadding, dip2px(10));
backgroundColor = a.getColor(R.styleable.ChatMessageView_backgroundColor, 0);
backgroundColorPressed = a.getColor(R.styleable.ChatMessageView_backgroundColorPressed, 0);
showArrow = a.getBoolean(R.styleable.ChatMessageView_cmv_showArrow, true);
arrowMargin = a.getDimension(R.styleable.ChatMessageView_cmv_arrowMargin, dip2px(5));
cornerRadius = a.getDimension(R.styleable.ChatMessageView_cmv_cornerRadius, 0);
contentPadding = a.getDimension(R.styleable.ChatMessageView_cmv_contentPadding, dip2px(10));
backgroundColor = a.getColor(R.styleable.ChatMessageView_cmv_backgroundColor, 0);
backgroundColorPressed = a.getColor(R.styleable.ChatMessageView_cmv_backgroundColorPressed, 0);

int intPosition = a.getInt(R.styleable.ChatMessageView_arrowPosition, ArrowPosition.LEFT.getValue());
int intPosition = a.getInt(R.styleable.ChatMessageView_cmv_arrowPosition, ArrowPosition.LEFT.getValue());
arrowPosition = ArrowPosition.getEnum(intPosition);

int intGravity = a.getInt(R.styleable.ChatMessageView_arrowGravity, ArrowGravity.START.getValue());
int intGravity = a.getInt(R.styleable.ChatMessageView_cmv_arrowGravity, ArrowGravity.START.getValue());
arrowGravity = ArrowGravity.getEnum(intGravity);

a.recycle();
Expand Down
16 changes: 8 additions & 8 deletions chat-message-view/src/main/res/values/attrs.xml
@@ -1,23 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="ChatMessageView">
<attr name="showArrow" format="boolean" />
<attr name="arrowPosition" format="enum">
<attr name="cmv_showArrow" format="boolean" />
<attr name="cmv_arrowPosition" format="enum">
<enum name="left" value="0" />
<enum name="right" value="1" />
<enum name="top" value="2" />
<enum name="bottom" value="3" />
</attr>
<attr name="arrowGravity" format="enum">
<attr name="cmv_arrowGravity" format="enum">
<enum name="start" value="0" />
<enum name="center" value="1" />
<enum name="end" value="2" />
</attr>
<attr name="backgroundColor" format="color" />
<attr name="backgroundColorPressed" format="color" />
<attr name="cornerRadius" format="dimension" />
<attr name="contentPadding" format="dimension" />
<attr name="arrowMargin" format="dimension" />
<attr name="cmv_backgroundColor" format="color" />
<attr name="cmv_backgroundColorPressed" format="color" />
<attr name="cmv_cornerRadius" format="dimension" />
<attr name="cmv_contentPadding" format="dimension" />
<attr name="cmv_arrowMargin" format="dimension" />

</declare-styleable>

Expand Down
4 changes: 2 additions & 2 deletions example/build.gradle
Expand Up @@ -22,6 +22,6 @@ android {
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'me.himanshusoni.chatmessageview:chat-message-view:1.0.1'
// compile project(':chat-message-view')
// compile 'me.himanshusoni.chatmessageview:chat-message-view:1.0.2'
compile project(':chat-message-view')
}
3 changes: 1 addition & 2 deletions example/example.iml
Expand Up @@ -73,7 +73,6 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/23.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/me.himanshusoni.chatmessageview/chat-message-view/1.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
Expand All @@ -92,8 +91,8 @@
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="appcompat-v7-23.0.0" level="project" />
<orderEntry type="library" exported="" name="chat-message-view-1.0.1" level="project" />
<orderEntry type="library" exported="" name="support-v4-23.0.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-23.0.0" level="project" />
<orderEntry type="module" module-name="chat-message-view" exported="" />
</component>
</module>
18 changes: 9 additions & 9 deletions example/src/main/res/layout/item_mine_image.xml
Expand Up @@ -8,19 +8,19 @@
<me.himanshusoni.chatmessageview.ChatMessageView xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:arrowGravity="start"
app:arrowPosition="right"
app:arrowMargin="3dp"
app:contentPadding="3dp"
app:backgroundColor="#88BABABA"
app:backgroundColorPressed="#FFBABABA"
app:cornerRadius="3dp"
app:showArrow="true">
app:cmv_arrowGravity="start"
app:cmv_arrowMargin="3dp"
app:cmv_arrowPosition="right"
app:cmv_backgroundColor="#88BABABA"
app:cmv_backgroundColorPressed="#FFBABABA"
app:cmv_contentPadding="3dp"
app:cmv_cornerRadius="3dp"
app:cmv_showArrow="true">

<ImageView
android:background="#aaffffff"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#aaffffff"
android:src="@drawable/ic_launcher" />
</me.himanshusoni.chatmessageview.ChatMessageView>

Expand Down
16 changes: 8 additions & 8 deletions example/src/main/res/layout/item_mine_message.xml
Expand Up @@ -8,14 +8,14 @@
<me.himanshusoni.chatmessageview.ChatMessageView xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:arrowGravity="start"
app:arrowPosition="right"
app:arrowMargin="3dp"
app:contentPadding="10dp"
app:backgroundColor="#88BABABA"
app:backgroundColorPressed="#FFBABABA"
app:cornerRadius="3dp"
app:showArrow="true">
app:cmv_arrowGravity="start"
app:cmv_arrowMargin="3dp"
app:cmv_arrowPosition="right"
app:cmv_backgroundColor="#88BABABA"
app:cmv_backgroundColorPressed="#FFBABABA"
app:cmv_contentPadding="10dp"
app:cmv_cornerRadius="3dp"
app:cmv_showArrow="true">

<TextView
android:id="@+id/text"
Expand Down
16 changes: 8 additions & 8 deletions example/src/main/res/layout/item_other_image.xml
Expand Up @@ -9,18 +9,18 @@
<me.himanshusoni.chatmessageview.ChatMessageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:arrowGravity="start"
app:arrowPosition="left"
app:backgroundColor="#8800bcd4"
app:backgroundColorPressed="#ff00bcd4"
app:cornerRadius="3dp"
app:contentPadding="3dp"
app:showArrow="true">
app:cmv_arrowGravity="start"
app:cmv_arrowPosition="left"
app:cmv_backgroundColor="#8800bcd4"
app:cmv_backgroundColorPressed="#ff00bcd4"
app:cmv_contentPadding="3dp"
app:cmv_cornerRadius="3dp"
app:cmv_showArrow="true">

<ImageView
android:background="#aaffffff"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#aaffffff"
android:src="@drawable/ic_launcher" />
</me.himanshusoni.chatmessageview.ChatMessageView>

Expand Down
13 changes: 6 additions & 7 deletions example/src/main/res/layout/item_other_message.xml
Expand Up @@ -9,13 +9,12 @@
<me.himanshusoni.chatmessageview.ChatMessageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:arrowGravity="start"
app:arrowPosition="left"
app:backgroundColor="#8800bcd4"
app:backgroundColorPressed="#ff00bcd4"
app:cornerRadius="3dp"
app:showArrow="true"
>
app:cmv_arrowGravity="start"
app:cmv_arrowPosition="left"
app:cmv_backgroundColor="#8800bcd4"
app:cmv_backgroundColorPressed="#ff00bcd4"
app:cmv_cornerRadius="3dp"
app:cmv_showArrow="true">

<TextView
android:id="@+id/text"
Expand Down

0 comments on commit c0b18e0

Please sign in to comment.