Skip to content

Commit 9ed58ef

Browse files
author
manshan
committed
fix bug: after reading voice message, the unread rad flag icon is not removed
1 parent c035218 commit 9ed58ef

7 files changed

Lines changed: 151 additions & 25 deletions

File tree

93.1 KB
Binary file not shown.

mgandroid-teamtalk/src/com/mogujie/tt/adapter/MessageAdapter.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,6 @@ public class MessageAdapter extends BaseAdapter {
103103
private Logger logger = Logger.getLogger(MessageAdapter.class);
104104
private IMSession session;
105105
private IMServiceHelper imServiceHelper;
106-
private IMService imService;
107-
private IMMessageManager msgMgr;
108106

109107
public void setIMServiceHelper(IMServiceHelper imServiceHelper) {
110108
this.imServiceHelper = imServiceHelper;
@@ -919,8 +917,15 @@ public void onClick(View v) {
919917
return;
920918
}
921919
if (msgInfo.getMsgReadStatus() < SysConstant.MESSAGE_DISPLAYED) {
922-
920+
logger.d("chat#audio#set audio meessage read status");
921+
923922
updateItemReadState(msgInfo.msgId, SysConstant.MESSAGE_DISPLAYED);
923+
924+
IMService imService = imServiceHelper.getIMService();
925+
if (imService != null) {
926+
msgInfo.setMsgReadStatus(SysConstant.MESSAGE_DISPLAYED);
927+
imService.getDbManager().updateMessageContent(msgInfo);
928+
}
924929
}
925930

926931
if (AudioPlayerHandler.getInstance().isPlaying()) {
@@ -1138,7 +1143,7 @@ private void resendMsg(String msgId) {
11381143
return;
11391144
}
11401145

1141-
imService = imServiceHelper.getIMService();
1146+
IMService imService = imServiceHelper.getIMService();
11421147
if (imService != null) {
11431148
imService.getMessageManager().resendMessage(msgInfo);
11441149
}

mgandroid-teamtalk/src/com/mogujie/tt/config/ProtocolConstant.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,10 @@ public static void dump(boolean toSend, Header header) {
217217
public static final String LOGIN_IP1 = "122.225.68.125";
218218
public static final String LOGIN_IP2 = "101.68.218.125";
219219

220-
public static final int LOGIN_PORT = 18008;
220+
public static final int LOGIN_PORT = 9008;
221+
222+
//open source
223+
// public static final int LOGIN_PORT = 18008;
221224

222225

223226
// COMMAND_ID FOR LOGIN

mgandroid-teamtalk/src/com/mogujie/tt/config/SysConstant.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,17 @@ public interface SysConstant {
1313
String SESSION_ID_KEY = "session_id";
1414
String OPERATION_RESULT_KEY = "tt_opeartion_result";
1515
String STATUS_KEY = "status";
16+
17+
// todo eric
18+
// 122.225.68.125:8001
19+
20+
// String AVATAR_URL_PREFIX = "http://122.225.68.125:8600/";
21+
// String DOWNLOAD_IMAGE_URL_REPFIX = "http://122.225.68.125:8600/";
22+
// String UPLOAD_IMAGE_URL_PREFIX = "http://122.225.68.125:8600/";
1623

17-
18-
String AVATAR_URL_PREFIX = "http://122.225.68.125:8600/";
19-
String DOWNLOAD_IMAGE_URL_REPFIX = "http://122.225.68.125:8600/";
20-
String UPLOAD_IMAGE_URL_PREFIX = "http://122.225.68.125:8600/";
24+
String AVATAR_URL_PREFIX = "http://122.225.68.125:8001/";
25+
String DOWNLOAD_IMAGE_URL_REPFIX = "http://122.225.68.125:8001/";
26+
String UPLOAD_IMAGE_URL_PREFIX = "http://122.225.68.125:8001/";
2127

2228
public static final int PROTOCOL_HEADER_LENGTH = 12;// 默认消息头的长度
2329
public static final int PROTOCOL_VERSION = 3;

mgandroid-teamtalk/src/com/mogujie/tt/imlib/db/IMDbManager.java

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,8 @@ public synchronized void updatePictureMessagePath(MessageInfo msg) {
170170
}
171171

172172
public synchronized void updateMessageStatus(MessageInfo msg) {
173-
if (msg.isAudioType()) {
174-
logger.d("updateMessageStatus audio type");
175-
}
173+
logger.d("db#updateMessageStatus msg:%s", msg);
174+
176175
SQLiteDatabase db = getWritableDatabase();
177176
if (db == null) {
178177
return;
@@ -185,6 +184,24 @@ public synchronized void updateMessageStatus(MessageInfo msg) {
185184

186185
db.execSQL(sql);
187186
}
187+
188+
189+
public synchronized void updateMessageContent(MessageInfo msg) {
190+
logger.d("db#updateMessageContent msg:%s", msg);
191+
192+
SQLiteDatabase db = getWritableDatabase();
193+
if (db == null) {
194+
return;
195+
}
196+
197+
String sqlFormat = "update session_msg set content=? where msg_id=?";
198+
199+
logger.d("db#upateMessageStatus sql:%s", sqlFormat);
200+
201+
db.execSQL(sqlFormat, new Object[]{msg.getContent(), msg.msgId});
202+
}
203+
204+
188205

189206
public synchronized void saveLoginIdentity(String loginId, String pwd) {
190207
logger.d("db#loginId:%s", loginId);
@@ -328,6 +345,7 @@ private void tryRecoverAudioMsg(MessageInfo msgInfo, String content) {
328345
MessageEntity.AudioInfo audioInfo = MessageEntity.AudioInfo.create(content);
329346
msgInfo.setPlayTime(audioInfo.getLength());
330347
msgInfo.setSavePath(audioInfo.getPath());
348+
msgInfo.setMsgReadStatus(audioInfo.getReadStatus());
331349
}
332350
}
333351

mgandroid-teamtalk/src/com/mogujie/tt/imlib/proto/MessageEntity.java

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ public static String createAudioInfo(MessageInfo msgInfo) {
164164
try {
165165
jo.put("path", msgInfo.getSavePath());
166166
jo.put("length", msgInfo.getPlayTime());
167+
jo.put("readStatus", msgInfo.getMsgReadStatus());
167168
return jo.toString();
168169
} catch (JSONException e) {
169170
Logger logger = Logger.getLogger(MessageEntity.class);
@@ -203,6 +204,18 @@ public static String createPicInfo(MessageInfo msgInfo) {
203204
return "";
204205
}
205206
public static class AudioInfo {
207+
private String path;
208+
private int length;
209+
private int readStatus;
210+
211+
public int getReadStatus() {
212+
return readStatus;
213+
}
214+
215+
public void setReadStatus(int readStatus) {
216+
this.readStatus = readStatus;
217+
}
218+
206219
public String getPath() {
207220
return path;
208221
}
@@ -219,30 +232,33 @@ public void setLength(int length) {
219232
this.length = length;
220233
}
221234

222-
private String path;
223-
private int length;
224-
225-
public AudioInfo(String path, int length) {
235+
public AudioInfo(String path, int length, int readStatus) {
226236
this.path = path;
227237
this.length = length;
238+
this.readStatus = readStatus;
228239

229-
Logger.getLogger(MessageEntity.class).d("audio#path:%s, length:%d", path, length);
240+
Logger.getLogger(MessageEntity.class).d("audio#path:%s, length:%d, readStatus", path, length, readStatus);
230241
}
231242

232243
public static AudioInfo create(String info) {
233-
JSONObject jo;
244+
Logger logger = Logger.getLogger(AudioInfo.class);
245+
String path = "";
246+
int length = 0;
247+
int readStatus = SysConstant.MESSAGE_UNREAD;
234248
try {
235-
jo = new JSONObject(info);
236-
return new AudioInfo((String) jo.get("path"), (Integer) jo.get("length"));
249+
JSONObject jo = new JSONObject(info);
250+
251+
path = jo.getString("path");
252+
length = jo.getInt("length");
253+
readStatus = jo.getInt("readStatus");
237254

238255
} catch (JSONException e1) {
239-
Logger logger = Logger.getLogger(MessageEntity.class);
240256
// TODO Auto-generated catch block
241-
logger.d("audio#createAudioInfo failed");
257+
logger.w("audio#createAudioInfo failed");
242258
}
243-
244-
return null;
245-
259+
260+
logger.d("audio#read audio info from db -> path:%s, length:%d, readStatus:%d", path, length, readStatus);
261+
return new AudioInfo(path, length, readStatus);
246262
}
247263
}
248264

mgandroid-teamtalk/src/com/mogujie/tt/ui/activity/LoginActivity.java

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
import java.util.ArrayList;
44
import java.util.List;
55

6+
import org.apache.http.Header;
7+
import org.json.JSONArray;
8+
import org.json.JSONObject;
9+
610
import android.content.BroadcastReceiver;
711
import android.content.Context;
812
import android.content.Intent;
@@ -15,6 +19,10 @@
1519
import android.widget.TextView;
1620
import android.widget.Toast;
1721

22+
import com.loopj.android.http.AsyncHttpClient;
23+
import com.loopj.android.http.JsonHttpResponseHandler;
24+
import com.loopj.android.http.PersistentCookieStore;
25+
import com.loopj.android.http.RequestParams;
1826
import com.mogujie.tt.R;
1927
import com.mogujie.tt.app.IMEntrance;
2028
import com.mogujie.tt.cache.biz.CacheHub;
@@ -55,6 +63,9 @@ public class LoginActivity extends TTBaseActivity implements OnIMServiceListner
5563
public static Context instance = null;
5664

5765
private LoginIdentity loginIdentity;
66+
67+
private AsyncHttpClient client = new AsyncHttpClient();
68+
private PersistentCookieStore myCookieStore;
5869

5970
// public static Handler getUiHandler() {
6071
//
@@ -139,12 +150,79 @@ public void onIMServiceConnected() {
139150
}
140151
}
141152

153+
private void reqLoginServerAddrs () {
154+
RequestParams paramMap = new RequestParams();
155+
paramMap.put("imclient", "1.0");
156+
paramMap.put("macim", "ooxx");
157+
paramMap.put("remember", "1");
158+
paramMap.put("user_email", "满山");
159+
paramMap.put("user_pass", "xmg9273168275");
160+
161+
client.setUserAgent("Android-TT");
162+
client.post("http://www.mogujie.com/user/zlogin/", paramMap, new JsonHttpResponseHandler() {
163+
164+
@Override
165+
public void onFailure(int statusCode, Header[] headers,
166+
String responseString, Throwable throwable) {
167+
logger.d("login#onFailure1, responseString:%s", responseString);
168+
super.onFailure(statusCode, headers, responseString, throwable);
169+
}
170+
171+
@Override
172+
public void onFailure(int statusCode, Header[] headers,
173+
Throwable throwable, JSONArray errorResponse) {
174+
logger.d("login#onFailure2, errorResponse:%s", errorResponse);
175+
176+
super.onFailure(statusCode, headers, throwable, errorResponse);
177+
}
178+
179+
@Override
180+
public void onFailure(int statusCode, Header[] headers,
181+
Throwable throwable, JSONObject errorResponse) {
182+
logger.d("login#onFailure3, errorResponse:%s", errorResponse);
183+
184+
super.onFailure(statusCode, headers, throwable, errorResponse);
185+
}
186+
187+
@Override
188+
public void onSuccess(int statusCode, Header[] headers,
189+
JSONArray response) {
190+
logger.d("login#onSuccess1, response:%s", response);
191+
192+
super.onSuccess(statusCode, headers, response);
193+
}
194+
195+
@Override
196+
public void onSuccess(int statusCode, Header[] headers,
197+
JSONObject response) {
198+
logger.d("login#onSuccess2, response:%s", response);
199+
200+
super.onSuccess(statusCode, headers, response);
201+
}
202+
203+
@Override
204+
public void onSuccess(int statusCode, Header[] headers,
205+
String responseString) {
206+
logger.d("login#onSuccess3, responseString:%s", responseString);
207+
208+
super.onSuccess(statusCode, headers, responseString);
209+
}
210+
211+
});
212+
}
213+
214+
142215
@Override
143216
protected void onCreate(Bundle savedInstanceState) {
144217

145218
super.onCreate(savedInstanceState);
146219

147220
logger.d("login#onCreate");
221+
222+
myCookieStore = new PersistentCookieStore(this);
223+
client.setCookieStore(myCookieStore);
224+
225+
reqLoginServerAddrs();
148226

149227
List<String> actions = new ArrayList<String>();
150228
actions.add(IMActions.ACTION_LOGIN_RESULT);

0 commit comments

Comments
 (0)