通知提醒设置新增个播开播通知设置

This commit is contained in:
huangjian
2022-07-18 15:27:11 +08:00
parent 1cfdd1e5a0
commit bd0a210804
4 changed files with 82 additions and 25 deletions

View File

@@ -1,5 +1,6 @@
package com.yizhuan.erban.ui.setting;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
@@ -30,6 +31,12 @@ public class NoticeSettingActivity extends BaseActivity {
@BindView(R.id.ll_container)
LinearLayout llContainer;
private View systemNoticeView;
private TutuSwitchView switchSystemNotice;
private boolean notifyMsg = false;
private View attentionNoticeView;
private TutuSwitchView switchAttentionNotice;
private boolean notifyAttention = false;
public static void start(Context context) {
StatisticManager.Instance().onEvent(StatisticsProtocol.EVENT_SETTING_NOTICE,
@@ -38,11 +45,7 @@ public class NoticeSettingActivity extends BaseActivity {
context.startActivity(intent);
}
private View systemNoticeView;
private TutuSwitchView switchSystemNotice;
private boolean notifyMsg = false;
@SuppressLint("CheckResult")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -53,8 +56,12 @@ public class NoticeSettingActivity extends BaseActivity {
SettingsModel.get().getSysMsgNotify()
.compose(bindUntilEvent(ActivityEvent.DESTROY))
.subscribe(result -> {
notifyMsg = result.isSysMsgNotify();
initSystemNotice();
notifyAttention = result.isSingleBroadcastMsgNotify();
initAttentionNotice();
});
}
@@ -96,6 +103,40 @@ public class NoticeSettingActivity extends BaseActivity {
}
private void initAttentionNotice() {
if (attentionNoticeView == null) {
attentionNoticeView = LayoutInflater.from(context).inflate(R.layout.item_system_notice, null);
switchAttentionNotice = attentionNoticeView.findViewById(R.id.switch_notice);
llContainer.addView(attentionNoticeView, new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
getResources().getDimensionPixelOffset(R.dimen.dp_setting_sys_notice_item_height))
);
setName(attentionNoticeView, "开播通知");
setDesc(attentionNoticeView, "关闭后,官方小秘书不再提示您关注主播的开播情况");
}
switchAttentionNotice.setOn(notifyAttention);
switchAttentionNotice.setOnSwitchStateChangeListener(new IOSSwitchView.OnSwitchStateChangeListener() {
@Override
public void onStateSwitched(boolean isOn) {
SettingsModel.get().setAttentionMsgNotify(isOn)
.compose(bindUntilEvent(ActivityEvent.DESTROY))
.subscribe(new DontWarnObserver<String>() {
@Override
public void accept(String s, String error) {
super.accept(s, error);
if (error == null) {
notifyAttention = isOn;
} else {
toast(error);
}
}
});
}
});
}
private void setName(View targetView, String name) {
if (targetView == null) {
return;

View File

@@ -25,6 +25,8 @@ public interface ISettingsModel extends IModel {
Single<String> setSysMsgNotify(boolean sysMsgNotify);
Single<String> setAttentionMsgNotify(boolean attentionMsgNotify);
Single<SysAccount> getSysAccount();
Single<String> interactiveMsgNotify(boolean interactiveMsgNotify);

View File

@@ -28,6 +28,10 @@ public class SettingsModel implements ISettingsModel {
private static SettingsModel instance;
private final Api api;
private SettingsModel() {
api = RxNet.create(Api.class);
}
public static ISettingsModel get() {
if (instance == null) {
synchronized (SettingsModel.class) {
@@ -39,10 +43,6 @@ public class SettingsModel implements ISettingsModel {
return instance;
}
private SettingsModel() {
api = RxNet.create(Api.class);
}
@Override
public Single<ServiceResult<String>> showLocation(long uid, boolean showLocation) {
return api.showLocation(uid, showLocation);
@@ -79,6 +79,12 @@ public class SettingsModel implements ISettingsModel {
.compose(RxHelper.handleIgnoreData()));
}
@Override
public Single<String> setAttentionMsgNotify(boolean attentionMsgNotify) {
return api.apiAttentionMsgNotify(AuthModel.get().getCurrentUid(), attentionMsgNotify)
.compose(RxHelper.handleIgnoreData());
}
private Single<Boolean> setNotifyAccount(String account, boolean notify) {
return Single.create((SingleOnSubscribe<Boolean>) e ->
NIMClient.getService(FriendService.class).setMessageNotify(account, notify)
@@ -136,8 +142,14 @@ public class SettingsModel implements ISettingsModel {
Single<ServiceResult<JsonElement>> apiSysMsgNotify(@Query("uid") long uid,
@Query("sysMsgNotify") boolean sysMsgNotify);
@FormUrlEncoded
@POST("/user/singleBroadcastMsgNotify")
Single<ServiceResult<JsonElement>> apiAttentionMsgNotify(@Field("uid") long uid,
@Field("msgNotify") boolean sysMsgNotify);
/**
* 获得小秘书和系统通知uid
*
* @return
*/
@GET("client/prop")

View File

@@ -766,6 +766,8 @@ public class UserInfo implements Serializable {
* 互动消息通知true:提醒
*/
private boolean interactiveMsgNotify = true;
private boolean singleBroadcastMsgNotify;
}
/**