Skip to content

Commit

Permalink
Merge pull request #57 from Meiqia/develop
Browse files Browse the repository at this point in the history
v3.1.1
  • Loading branch information
ksxkq committed Mar 1, 2016
2 parents a3851b6 + 497f42b commit 4377129
Show file tree
Hide file tree
Showing 44 changed files with 672 additions and 210 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Change Log
==========

Version 3.1.1 *(2016-02-29)*
----------------------------

- 增加显示客服留言功能
- 优化图片浏览
- 修复从文件选择图片发送崩溃问题

Version 3.1.0 *(2016-02-03)*
----------------------------

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

```
// required
// 「latestVersion」改成 maven central 徽章后面对应的版本号,例如3.0.3
compile 'com.meiqia:meiqiasdk:latestVersion@aar'
// 「3.1.1」改成 maven central 徽章后面对应的版本号,例如3.1.1
compile 'com.meiqia:meiqiasdk:3.1.1@aar'
// 在下面的依赖中,如果你的项目已经依赖过其中的组件,则不需要重复依赖
compile 'com.android.support:support-v4:23.1.1'
Expand Down
Binary file removed eclipse/MeiqiaSdk/libs/meiqia-3.1.0.jar
Binary file not shown.
Binary file added eclipse/MeiqiaSdk/libs/meiqia-3.1.1.jar
Binary file not shown.
16 changes: 16 additions & 0 deletions eclipse/MeiqiaSdk/res/anim/mq_view_photo_enter.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<scale
android:duration="300"
android:fromXScale="0"
android:fromYScale="0"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="1"
android:toYScale="1" />
<alpha
android:duration="300"
android:fromAlpha="0"
android:toAlpha="1" />
</set>
16 changes: 16 additions & 0 deletions eclipse/MeiqiaSdk/res/anim/mq_view_photo_exit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<scale
android:duration="300"
android:fromXScale="1"
android:fromYScale="1"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="0"
android:toYScale="0" />
<alpha
android:duration="300"
android:fromAlpha="1"
android:toAlpha="0" />
</set>
Binary file added eclipse/MeiqiaSdk/res/drawable-xxhdpi/mq_ic_save.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions eclipse/MeiqiaSdk/res/drawable/mq_trans_btn.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape>
<solid android:color="#26000000" />
<stroke android:width="1px" android:color="#DDDDDD" />
<corners android:radius="3dp" />
</shape>
</item>

<item>
<shape>
<solid android:color="#1A000000" />
<stroke android:width="1px" android:color="@android:color/white" />
<corners android:radius="3dp" />
</shape>
</item>
</selector>
1 change: 1 addition & 0 deletions eclipse/MeiqiaSdk/res/layout/mq_activity_conversation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
android:minHeight="40dp"
android:textColor="@color/mq_chat_text_left"
android:textSize="@dimen/mq_textSize_level2"
android:hint="@string/mq_send_msg"
tools:text="测试文本" />


Expand Down
28 changes: 23 additions & 5 deletions eclipse/MeiqiaSdk/res/layout/mq_dialog_view_photo.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/MQMatchMatch"
android:background="@color/mq_dialog_bg_translucent">
android:background="@android:color/black">

<ImageView
android:id="@+id/iv_view_photo"
style="@style/MQMatchMatch"
android:layout_centerInParent="true"
android:adjustViewBounds="true"
android:scaleType="centerInside" />
style="@style/MQMatchMatch" />

<Button
android:id="@+id/btn_save"
style="@style/MQWrapWrap"
android:layout_alignParentBottom="true"
android:layout_marginBottom="@dimen/mq_size_level3"
android:layout_marginLeft="@dimen/mq_size_level2"
android:background="@drawable/mq_trans_btn"
android:button="@null"
android:paddingBottom="@dimen/mq_size_level2"
android:paddingLeft="@dimen/mq_size_level3"
android:paddingRight="@dimen/mq_size_level3"
android:paddingTop="@dimen/mq_size_level2"
android:text="@string/mq_save"
android:textColor="@android:color/white"
android:textSize="@dimen/mq_textSize_level1" />

<ProgressBar
android:id="@+id/progress_bar"
style="@style/MQWrapWrap"
android:layout_centerInParent="true" />

</RelativeLayout>
10 changes: 9 additions & 1 deletion eclipse/MeiqiaSdk/res/values/mq_strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,12 @@
<string name="mq_download_audio_failure">下载录音失败!</string>
<string name="mq_recorder_no_permission">没有录音权限!</string>
<string name="mq_recorder_remaining_time">还可以说 %1$s 秒</string>
</resources>

<string name="mq_view_photo">查看图片</string>
<string name="mq_download_img_failure">下载到图片失败</string>
<string name="mq_save_img_failure">保存图片失败,再试试?</string>
<string name="mq_save_img_success">图片已保存至 %s 文件夹</string>

<string name="mq_send_msg">发送消息</string>
<string name="mq_save">保存</string>
</resources>
9 changes: 9 additions & 0 deletions eclipse/MeiqiaSdk/res/values/mq_styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,17 @@
<item name="android:windowIsFloating">true</item>
</style>

<style name="MQDialog.Nodim">
<item name="android:backgroundDimEnabled">false</item>
</style>

<style name="MQTheme" parent="@android:style/Theme.Light.NoTitleBar"></style>

<style name="MQPhotoDialogAnim" parent="android:Animation">
<item name="android:windowEnterAnimation">@anim/mq_view_photo_enter</item>
<item name="android:windowExitAnimation">@anim/mq_view_photo_exit</item>
</style>

<style name="MQWrapMatch">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">match_parent</item>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.meiqia.meiqiasdk.activity;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
Expand All @@ -20,6 +21,7 @@
import android.support.v4.widget.SwipeRefreshLayout;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
Expand All @@ -30,6 +32,7 @@
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.meiqia.core.callback.OnEvaluateCallback;
Expand Down Expand Up @@ -82,8 +85,10 @@ public class MQConversationActivity extends Activity implements View.OnClickList
private static MQController controller;

// 控件
private View backBtn;
private RelativeLayout titleRl;
private RelativeLayout backRl;
private TextView backTv;
private ImageView backIv;
private TextView titleTv;
private ListView conversationListView;
private EditText inputEt;
Expand Down Expand Up @@ -125,8 +130,8 @@ protected void onCreate(final Bundle savedInstanceState) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); // 保持屏幕长亮
setContentView(R.layout.mq_activity_conversation);

init();
findViews();
init();
setListeners();
applyConfig();
registerReceiver();
Expand All @@ -139,15 +144,25 @@ protected void onCreate(final Bundle savedInstanceState) {
*/
private void applyConfig() {
if (MQConfig.DEFAULT != MQConfig.bgColorTitle) {
View titleRl = findViewById(R.id.title_rl);
Drawable tintDrawable = MQUtils.tintDrawable(this, titleRl.getBackground(), MQConfig.bgColorTitle);
MQUtils.setBackground(titleRl, tintDrawable);
}

if (MQConfig.DEFAULT != MQConfig.backArrowIconResId) {
backIv.setImageResource(MQConfig.backArrowIconResId);
}

if (MQConfig.MQTitleGravity.LEFT == MQConfig.titleGravity) {
RelativeLayout.LayoutParams titleTvParams = (RelativeLayout.LayoutParams) titleTv.getLayoutParams();
titleTvParams.addRule(RelativeLayout.RIGHT_OF, R.id.back_rl);
titleTv.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
backTv.setVisibility(View.GONE);
}

if (MQConfig.DEFAULT != MQConfig.textColorTitle) {
titleTv.setTextColor(getResources().getColor(MQConfig.textColorTitle));
backTv.setTextColor(getResources().getColor(MQConfig.textColorTitle));
ImageView backIconIv = (ImageView) findViewById(R.id.back_iv);
backIconIv.setColorFilter(MQConfig.textColorTitle);
backIv.setColorFilter(getResources().getColor(MQConfig.textColorTitle));
}
}

Expand Down Expand Up @@ -180,6 +195,10 @@ protected void onDestroy() {
mSoundPoolManager.release();
LocalBroadcastManager.getInstance(this).unregisterReceiver(messageReceiver);
unregisterReceiver(networkChangeReceiver);
// 退出的时候,如果没有客服,关闭服务
if (currentAgent == null) {
controller.closeService();
}
} catch (Exception e) {
//有些时候会出现未注册就取消注册的情况,暂时不知道为什么
}
Expand Down Expand Up @@ -210,11 +229,15 @@ private void init() {
mHandler = new Handler();

mSoundPoolManager = MQSoundPoolManager.getInstance(this);
chatMsgAdapter = new MQChatAdapter(MQConversationActivity.this, chatMessageList, conversationListView);
conversationListView.setAdapter(chatMsgAdapter);
}

private void findViews() {
backBtn = findViewById(R.id.back_rl);
titleRl = (RelativeLayout) findViewById(R.id.title_rl);
backRl = (RelativeLayout) findViewById(R.id.back_rl);
backTv = (TextView) findViewById(R.id.back_tv);
backIv = (ImageView) findViewById(R.id.back_iv);
conversationListView = (ListView) findViewById(R.id.messages_lv);
inputEt = (EditText) findViewById(R.id.input_et);
emojiSelectBtn = findViewById(R.id.emoji_select_btn);
Expand All @@ -232,7 +255,7 @@ private void findViews() {
}

private void setListeners() {
backBtn.setOnClickListener(this);
backRl.setOnClickListener(this);
sendTextBtn.setOnClickListener(this);
photoSelectBtn.setOnClickListener(this);
cameraSelectBtn.setOnClickListener(this);
Expand Down Expand Up @@ -434,7 +457,7 @@ public void onSuccess(final List<BaseMessage> messageList) {
cleanVoiceMessage(messageList);
//添加时间戳
MQTimeUtils.refreshMQTimeItem(messageList);
chatMsgAdapter.loadMoreMessage(messageList);
chatMsgAdapter.loadMoreMessage(cleanDupMessages(chatMessageList, messageList));
conversationListView.setSelection(messageList.size());
swipeRefreshLayout.setRefreshing(false);
// 没有消息后,禁止下拉加载
Expand Down Expand Up @@ -466,7 +489,7 @@ public void onSuccess(final List<BaseMessage> messageList) {
cleanVoiceMessage(messageList);
//添加时间戳
MQTimeUtils.refreshMQTimeItem(messageList);
chatMsgAdapter.loadMoreMessage(messageList);
chatMsgAdapter.loadMoreMessage(cleanDupMessages(chatMessageList, messageList));
conversationListView.setSelection(messageList.size());
swipeRefreshLayout.setRefreshing(false);
// 没有消息后,禁止下拉加载
Expand All @@ -483,6 +506,23 @@ public void onFailure(int code, String responseString) {
});
}

/**
* 过滤掉列表存在的消息
* @param messageList 列表中的消息
* @param newMessageList 加载的新消息
* @return
*/
private List<BaseMessage> cleanDupMessages(List<BaseMessage> messageList, List<BaseMessage> newMessageList) {
Iterator<BaseMessage> iterator = newMessageList.iterator();
while (iterator.hasNext()) {
BaseMessage newMessage = iterator.next();
if (messageList.contains(newMessage)) {
iterator.remove();
}
}
return newMessageList;
}

/**
* 设置顾客上线
*/
Expand Down Expand Up @@ -581,10 +621,9 @@ private void loadData() {
message.setStatus(BaseMessage.STATE_ARRIVE);
}
}
chatMsgAdapter = new MQChatAdapter(MQConversationActivity.this, chatMessageList, conversationListView);
conversationListView.setAdapter(chatMsgAdapter);
MQUtils.scrollListViewToBottom(conversationListView);
chatMsgAdapter.downloadAndNotifyDataSetChanged(chatMessageList);
chatMsgAdapter.notifyDataSetChanged();
hasLoadData = true;
}

Expand Down Expand Up @@ -883,7 +922,8 @@ private void renameVoiceFilename(BaseMessage message) {

// 监听EditText输入框数据到变化
private TextWatcher inputTextWatcher = new MQSimpleTextWatcher() {
@Override
@SuppressLint("NewApi")
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
// 向服务器发送一个正在输入的函数
if (!TextUtils.isEmpty(s)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,9 @@ public void executeEvaluate(String conversationId, int level, String content, On
MQManager.getInstance(context).executeEvaluate(conversationId, level, content, onEvaluateCallback);
}

@Override
public void closeService() {
MQManager.getInstance(context).closeMeiqiaService();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,6 @@ public interface MQController {
* @param onEvaluateCallback 评价的回调接口
*/
void executeEvaluate(String conversationId, int level, String content, OnEvaluateCallback onEvaluateCallback);

void closeService();
}
Loading

0 comments on commit 4377129

Please sign in to comment.