Skip to content

Commit

Permalink
Merge pull request #158 from jpush/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
KenChoi1992 authored Nov 28, 2017
2 parents 1f814f0 + 710769f commit 9d2520f
Show file tree
Hide file tree
Showing 29 changed files with 1,747 additions and 221 deletions.
2 changes: 1 addition & 1 deletion Android/chatinput/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apply plugin: 'com.android.library'
ext {
PUBLISH_GROUP_ID = 'cn.jiguang.imui'
PUBLISH_ARTIFACT_ID = 'chatinput'
PUBLISH_VERSION = '0.5.0'
PUBLISH_VERSION = '0.5.2'
}

android {
Expand Down
7 changes: 5 additions & 2 deletions Android/chatinput/src/main/res/layout/view_chatinput.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<LinearLayout
android:id="@+id/aurora_ll_input_container"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:orientation="horizontal">

Expand All @@ -19,7 +19,8 @@
<sj.keyboard.widget.EmoticonsEditText
android:id="@+id/aurora_et_chat_input"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:minHeight="48dp"
android:gravity="center_vertical"
android:layout_weight="1"
android:background="@drawable/aurora_edittext_bg"
Expand All @@ -28,6 +29,8 @@
android:inputType="textMultiLine"
android:paddingLeft="4dp"
android:paddingRight="4dp"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:maxLines="4"
android:textColor="@android:color/black"
android:textCursorDrawable="@drawable/aurora_edittext_cursor_bg"
Expand Down
2 changes: 1 addition & 1 deletion Android/messagelist/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apply plugin: 'com.android.library'
ext {
PUBLISH_GROUP_ID = 'cn.jiguang.imui'
PUBLISH_ARTIFACT_ID = 'messagelist'
PUBLISH_VERSION = '0.5.4'
PUBLISH_VERSION = '0.5.5'
}

android {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,14 @@ public void setSendingIndeterminateDrawable(String drawableName, String packageN
mMsgListStyle.setSendingIndeterminateDrawable(getResources().getDrawable(resId));
}

public void setLineSpacingExtra(int spacing) {
mMsgListStyle.setLineSpacingExtra(spacing);
}

public void setLineSpacingMultiplier(float mult) {
mMsgListStyle.setLineSpacingMultiplier(mult);
}

@Override
public boolean onDown(MotionEvent e) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ public class MessageListStyle extends Style {
private float bubbleMaxWidth;
private Drawable sendPhotoMsgBg;
private Drawable receivePhotoMsgBg;
private int lineSpacingExtra;
private float lineSpacingMultiplier;

private int windowWidth;
private Drawable sendingProgressDrawable;
Expand Down Expand Up @@ -135,7 +137,9 @@ public static MessageListStyle parse(Context context, AttributeSet attrs) {
context.getResources().getDimensionPixelSize(R.dimen.aurora_padding_send_text_right));
style.sendBubblePaddingBottom = typedArray.getDimensionPixelSize(R.styleable.MessageList_sendBubblePaddingBottom,
context.getResources().getDimensionPixelSize(R.dimen.aurora_padding_send_text_bottom));

style.lineSpacingExtra = typedArray.getDimensionPixelSize(R.styleable.MessageList_lineSpacingExtra,
context.getResources().getDimensionPixelSize(R.dimen.aurora_line_spacing_extra_default));
style.lineSpacingMultiplier = typedArray.getFloat(R.styleable.MessageList_lineSpacingMultiplier, 1.0f);
style.sendVoiceDrawable = typedArray.getResourceId(R.styleable.MessageList_sendVoiceDrawable,
R.drawable.aurora_sendvoice_send_3);
style.receiveVoiceDrawable = typedArray.getResourceId(R.styleable.MessageList_receiveVoiceDrawable,
Expand Down Expand Up @@ -521,4 +525,20 @@ public Drawable getSendingIndeterminateDrawable() {
public Drawable getSendingProgressDrawable() {
return sendingProgressDrawable;
}

public void setLineSpacingExtra(int spacing) {
this.lineSpacingExtra = spacing;
}

public int getLineSpacingExtra() {
return this.lineSpacingExtra;
}

public void setLineSpacingMultiplier(float mult) {
this.lineSpacingMultiplier = mult;
}

public float getLineSpacingMultiplier() {
return this.lineSpacingMultiplier;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public int getItemViewType(int position) {

private int getCustomType(IMessage message) {
for (int i=0; i < mCustomMsgList.size(); i++) {
CustomMsgConfig config = mCustomMsgList.valueAt(0);
CustomMsgConfig config = mCustomMsgList.valueAt(i);
if (message.getType().getCustomType() == config.getViewType()) {
return config.getViewType();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ public void onClick(View view) {
@Override
public void applyStyle(MessageListStyle style) {
mMsgTv.setMaxWidth((int) (style.getWindowWidth() * style.getBubbleMaxWidth()));
mMsgTv.setLineSpacing(style.getLineSpacingExtra(), style.getLineSpacingMultiplier());
if (mIsSender) {
mMsgTv.setBackground(style.getSendBubbleDrawable());
mMsgTv.setTextColor(style.getSendBubbleTextColor());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
android:layout_height="wrap_content"
android:layout_below="@id/aurora_tv_msgitem_receiver_display_name"
android:layout_centerVertical="true"
android:lineSpacingExtra="5dp"
android:layout_toRightOf="@id/aurora_iv_msgitem_avatar"
android:background="@drawable/aurora_receivetxt_bubble" />
</RelativeLayout>
Expand Down
1 change: 1 addition & 0 deletions Android/messagelist/src/main/res/layout/item_send_text.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
android:layout_below="@+id/aurora_tv_msgitem_sender_display_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:lineSpacingExtra="5dp"
android:layout_marginRight="3dp"
android:background="@drawable/aurora_sendtxt_bubble"
android:paddingRight="20dp"
Expand Down
2 changes: 2 additions & 0 deletions Android/messagelist/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
<attr name="receiveVoiceDrawable" format="reference"/>
<attr name="playSendVoiceAnim" format="reference"/>
<attr name="playReceiveVoiceAnim" format="reference"/>
<attr name="lineSpacingExtra" format="dimension|reference" />
<attr name="lineSpacingMultiplier" format="float" />

<attr name="sendPhotoMsgBg" format="reference"/>
<attr name="receivePhotoMsgBg" format="reference"/>
Expand Down
1 change: 1 addition & 0 deletions Android/messagelist/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<dimen name="aurora_padding_send_text_right">15dp</dimen>
<dimen name="aurora_padding_send_text_bottom">5dp</dimen>
<dimen name="aurora_radius_photo_default">5dp</dimen>
<dimen name="aurora_line_spacing_extra_default">5dp</dimen>


</resources>
2 changes: 1 addition & 1 deletion Android/sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ buildscript {
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@
app:receiveBubblePaddingLeft="16dp"
app:receiveBubblePaddingRight="8dp"
app:receiveTextColor="#ffffff"
app:receiveTextSize="14sp"
app:receiveTextSize="16sp"
app:sendBubblePaddingLeft="8dp"
app:sendBubblePaddingRight="16dp"
app:sendTextColor="#7587A8"
app:sendTextSize="14sp" />
app:sendTextSize="16sp" />

</cn.jiguang.imui.messages.ptr.PullToRefreshLayout>

Expand Down
2 changes: 1 addition & 1 deletion ReactNative/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ dependencies {
compile 'com.github.w446108264:XhsEmoticonsKeyboard:2.0.4'
compile 'com.github.w446108264:AndroidEmoji:1.0.0'
compile 'cn.jiguang.imui:messagelist:0.5.4'
compile 'cn.jiguang.imui:chatinput:0.5.0'
compile 'cn.jiguang.imui:chatinput:0.5.2'
compile 'org.greenrobot:eventbus:3.0.0'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.facebook.react:react-native:+'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import android.util.Log;

import com.facebook.react.bridge.Callback;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
Expand All @@ -15,17 +16,21 @@
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import cn.jiguang.imui.messagelist.event.GetTextEvent;
import cn.jiguang.imui.messagelist.event.LoadedEvent;
import cn.jiguang.imui.messagelist.event.MessageEvent;
import cn.jiguang.imui.messagelist.event.ScrollEvent;
import cn.jiguang.imui.messagelist.event.StopPlayVoiceEvent;

import static cn.jiguang.imui.messagelist.ReactMsgListManager.RCT_REMOVE_MESSAGE_ACTION;

public class AuroraIMUIModule extends ReactContextBaseJavaModule {

private final String REACT_MSG_LIST_MODULE = "AuroraIMUIModule";
public static final String RCT_MESSAGE_LIST_LOADED_ACTION = "cn.jiguang.imui.messagelist.intent.messageLoaded";

private static final String MESSAGE_LIST_DID_LOAD_EVENT = "IMUIMessageListDidLoad";
public static final String GET_INPUT_TEXT_EVENT = "getInputText";

public AuroraIMUIModule(ReactApplicationContext reactContext) {
super(reactContext);
Expand Down Expand Up @@ -57,6 +62,14 @@ public void onEvent(LoadedEvent event) {
}
}

@Subscribe(threadMode = ThreadMode.MAIN)
public void onEvent(GetTextEvent event) {
if (event.getAction().equals(GET_INPUT_TEXT_EVENT)) {
getReactApplicationContext().getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
.emit(GET_INPUT_TEXT_EVENT, event.getText());
}
}

@ReactMethod
public void hidenFeatureView(boolean flag) {

Expand Down Expand Up @@ -161,6 +174,12 @@ private RCTMessage configMessage(ReadableMap message) {
return rctMsg;
}

@ReactMethod
public void removeMessage(String id) {
MessageEvent event = new MessageEvent(id, RCT_REMOVE_MESSAGE_ACTION);
EventBus.getDefault().post(event);
}

@ReactMethod
public void scrollToBottom(boolean flag) {
EventBus.getDefault().post(new ScrollEvent(flag));
Expand Down
Loading

0 comments on commit 9d2520f

Please sign in to comment.