Skip to content

Commit f534148

Browse files
committed
user message receipt
1 parent 9004531 commit f534148

File tree

5 files changed

+48
-10
lines changed

5 files changed

+48
-10
lines changed

chat/kit/src/main/java/cn/wildfire/chat/kit/conversation/message/viewholder/NormalMessageContentViewHolder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ protected void setSendStatus(Message item) {
289289
return;
290290
}
291291

292-
if (!ChatManager.Instance().isReceiptEnabled()) {
292+
if (!ChatManager.Instance().isReceiptEnabled() && !ChatManager.Instance().isUserEnableReceipt()) {
293293
return;
294294
}
295295

chat/kit/src/main/java/cn/wildfire/chat/kit/settings/MessageNotifySettingActivity.java

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package cn.wildfire.chat.kit.settings;
22

3-
import android.widget.Switch;
3+
import android.widget.CompoundButton;
44
import android.widget.Toast;
55

66
import com.kyleduo.switchbutton.SwitchButton;
@@ -16,14 +16,14 @@ public class MessageNotifySettingActivity extends WfcBaseActivity {
1616
SwitchButton switchMsgNotification;
1717
@BindView(R.id.switchShowMsgDetail)
1818
SwitchButton switchShowMsgDetail;
19+
@BindView(R.id.switchUserReceipt)
20+
SwitchButton switchUserReceipt;
1921

2022
@Override
2123
protected int contentLayout() {
2224
return R.layout.activity_msg_notify_settings;
2325
}
2426

25-
26-
2727
@Override
2828
protected void afterViews() {
2929
super.afterViews();
@@ -59,5 +59,22 @@ public void onFail(int errorCode) {
5959
}
6060
});
6161
});
62+
63+
switchUserReceipt.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
64+
@Override
65+
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
66+
ChatManager.Instance().setUserEnableReceipt(b, new GeneralCallback() {
67+
@Override
68+
public void onSuccess() {
69+
70+
}
71+
72+
@Override
73+
public void onFail(int errorCode) {
74+
Toast.makeText(MessageNotifySettingActivity.this, "网络错误", Toast.LENGTH_SHORT);
75+
}
76+
});
77+
}
78+
});
6279
}
6380
}

chat/kit/src/main/res/layout/activity_msg_notify_settings.xml

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,11 @@
3434

3535
</FrameLayout>
3636

37-
<View style="@style/Line" />
38-
3937
<View
4038
android:layout_width="match_parent"
4139
android:layout_height="10dp"
4240
android:background="@color/gray5" />
4341

44-
<View style="@style/Line" />
45-
4642
<FrameLayout
4743
android:layout_width="match_parent"
4844
android:layout_height="50dp"
@@ -64,7 +60,27 @@
6460

6561
</FrameLayout>
6662

67-
<View style="@style/Line" />
63+
<FrameLayout
64+
android:layout_width="match_parent"
65+
android:layout_height="50dp"
66+
android:paddingLeft="@dimen/item_margin_left_and_right"
67+
android:paddingRight="@dimen/item_margin_left_and_right">
68+
69+
<TextView
70+
android:layout_width="wrap_content"
71+
android:layout_height="wrap_content"
72+
android:layout_gravity="center_vertical"
73+
android:text="消息回执"
74+
android:textColor="@color/black1"
75+
android:textSize="16sp" />
76+
77+
<com.kyleduo.switchbutton.SwitchButton
78+
android:id="@+id/switchUserReceipt"
79+
style="@style/IosSwitch"
80+
android:layout_gravity="center_vertical|right" />
81+
82+
</FrameLayout>
83+
6884

6985
</LinearLayout>
7086
</LinearLayout>

chat/src/main/res/layout/main_fragment_me.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
android:background="@drawable/selector_common_item"
7575
app:show_arrow_indicator="true"
7676
app:start_src="@mipmap/ic_notification"
77-
app:title="消息通知" />
77+
app:title="消息与通知" />
7878

7979
<cn.wildfire.chat.kit.widget.OptionItemView
8080
android:id="@+id/passwordOptionItemView"

client/src/main/java/cn/wildfirechat/remote/ChatManager.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ public class ChatManager {
119119
private boolean startLog;
120120
private int connectionStatus;
121121
private int receiptStatus = -1; // 1, enable
122+
private int userReceiptStatus = -1; //1, enable
122123

123124
private boolean isBackground = true;
124125
private List<OnReceiveMessageListener> onReceiveMessageListeners = new ArrayList<>();
@@ -4669,9 +4670,13 @@ public boolean isUserEnableReceipt() {
46694670
if (!checkRemoteService()) {
46704671
return false;
46714672
}
4673+
if (userReceiptStatus != -1) {
4674+
return userReceiptStatus == 1;
4675+
}
46724676

46734677
try {
46744678
boolean disable = "1".equals(mClient.getUserSetting(UserSettingScope.DisableReceipt, ""));
4679+
userReceiptStatus = disable ? 0 : 1;
46754680
return !disable;
46764681
} catch (RemoteException e) {
46774682
e.printStackTrace();

0 commit comments

Comments
 (0)