diff --git a/app/src/main/java/com/shayu/phonelive/AppContext.java b/app/src/main/java/com/shayu/phonelive/AppContext.java index c9bfb737c..33f2e91c7 100644 --- a/app/src/main/java/com/shayu/phonelive/AppContext.java +++ b/app/src/main/java/com/shayu/phonelive/AppContext.java @@ -32,9 +32,11 @@ import com.yunbao.common.http.HttpCallback; import com.yunbao.common.manager.imrongcloud.MessageIMManager; import com.yunbao.common.manager.imrongcloud.RongcloudIMManager; import com.yunbao.common.utils.L; +import com.yunbao.common.utils.SpUtil; import com.yunbao.live.socket.SocketRyClient; import com.yunbao.live.utils.LiveImDeletUtil; import com.yunbao.live.views.PortraitLiveManager; +import com.yunbao.main.activity.MsgSettActivity; import java.io.File; import java.io.IOException; @@ -226,7 +228,16 @@ public class AppContext extends CommonAppContext { } } }); + configSPApp(); + } + /** + * 配置SharedPreferences默认值 + */ + private void configSPApp(){ + if(!SpUtil.getInstance().isExists(MsgSettActivity.SWITCH_PRIVATE_CHAT_MSG)){ + SpUtil.getInstance().setBooleanValue(MsgSettActivity.SWITCH_PRIVATE_CHAT_MSG,true); + } } diff --git a/common/src/main/java/com/yunbao/common/utils/SpUtil.java b/common/src/main/java/com/yunbao/common/utils/SpUtil.java index cfb12648c..40604a237 100644 --- a/common/src/main/java/com/yunbao/common/utils/SpUtil.java +++ b/common/src/main/java/com/yunbao/common/utils/SpUtil.java @@ -70,6 +70,13 @@ public class SpUtil { return mSharedPreferences.getString(key, ""); } + /** + * 判断一个值是否存在 + */ + public boolean isExists(String key){ + return mSharedPreferences.contains(key); + } + /** * 保存多个字符串 */ diff --git a/live/src/main/java/com/yunbao/live/activity/PDLiveConversationActivity.java b/live/src/main/java/com/yunbao/live/activity/PDLiveConversationActivity.java index d058fae4e..a7e3fa643 100644 --- a/live/src/main/java/com/yunbao/live/activity/PDLiveConversationActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/PDLiveConversationActivity.java @@ -130,7 +130,7 @@ public class PDLiveConversationActivity extends AbsActivity implements View.OnCl super.onWindowFocusChanged(hasFocus); if(hasFocus&&isDialogWindow){ ViewGroup.LayoutParams params = mRootLayout.getLayoutParams(); - params.height= DpUtil.dp2px(400); + params.height= DpUtil.dp2px(500); mRootLayout.setLayoutParams(params); } } diff --git a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java index 05b49a105..010c7ce02 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -69,6 +69,7 @@ import com.yunbao.common.utils.DialogUitl; import com.yunbao.common.utils.DpUtil; import com.yunbao.common.utils.RouteUtil; import com.yunbao.common.utils.ScreenDimenUtil; +import com.yunbao.common.utils.SpUtil; import com.yunbao.common.utils.StringUtil; import com.yunbao.common.utils.WordUtil; import com.yunbao.common.utils.formatBigNum; @@ -655,6 +656,10 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis ViewClicksAntiShake.clicksAntiShake(msg, this::openChatWindow); ViewClicksAntiShake.clicksAntiShake(msg2, this::openChatWindow); + if(!SpUtil.getInstance().getBooleanValue("private_chat_message_switch")){ + msgLayout.setVisibility(View.GONE); + } + mHandler = new Handler() { @Override public void handleMessage(Message msg) { diff --git a/main/src/main/java/com/yunbao/main/activity/MsgSettActivity.java b/main/src/main/java/com/yunbao/main/activity/MsgSettActivity.java index 05c52cbb8..f7a7a3e72 100644 --- a/main/src/main/java/com/yunbao/main/activity/MsgSettActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/MsgSettActivity.java @@ -16,6 +16,7 @@ import com.yunbao.common.bean.SlideInfoModel; import com.yunbao.common.http.ResponseData; import com.yunbao.common.http.base.HttpCallback; import com.yunbao.common.http.main.MainNetManager; +import com.yunbao.common.utils.SpUtil; import com.yunbao.common.utils.ToastUtil; import com.yunbao.live.views.LoadingView; import com.yunbao.main.R; @@ -26,7 +27,8 @@ import java.util.List; public class MsgSettActivity extends AbsActivity { - ImageView dt_switch,hdd_switch,lt_switch,xt_switch,kb_switch; + ImageView dt_switch,hdd_switch,lt_switch,xt_switch,kb_switch,privateChatMessageSwitch; + public static final String SWITCH_PRIVATE_CHAT_MSG="private_chat_message_switch"; RecyclerView follow_list; @Override @@ -44,6 +46,7 @@ public class MsgSettActivity extends AbsActivity { lt_switch = (ImageView) findViewById(R.id.lt_switch); xt_switch= (ImageView) findViewById(R.id.xt_switch); kb_switch= (ImageView) findViewById(R.id.kb_switch); + privateChatMessageSwitch=findViewById(R.id.private_chat_switch); getData(); dt_switch.setOnClickListener(new View.OnClickListener() { @Override @@ -145,6 +148,26 @@ public class MsgSettActivity extends AbsActivity { }); } }); + /* privateChatMessageSwitch.setOnClickListener(view -> { + if (privateChatMessageSwitch.getDrawable().getCurrent().getConstantState().equals(getResources().getDrawable(R.mipmap.special_icon_on).getConstantState())){ + if(setMsgMasterSwitch("2","5")){ + privateChatMessageSwitch.setImageResource(R.mipmap.special_icon_off); + } + }else{ + if(setMsgMasterSwitch("1","5")){ + privateChatMessageSwitch.setImageResource(R.mipmap.special_icon_on); + } + } + });*/ + privateChatMessageSwitch.setOnClickListener(view -> { + if (privateChatMessageSwitch.getDrawable().getCurrent().getConstantState().equals(getResources().getDrawable(R.mipmap.special_icon_on).getConstantState())){ + privateChatMessageSwitch.setImageResource(R.mipmap.special_icon_off); + SpUtil.getInstance().setBooleanValue(SWITCH_PRIVATE_CHAT_MSG,false); + }else{ + privateChatMessageSwitch.setImageResource(R.mipmap.special_icon_on); + SpUtil.getInstance().setBooleanValue(SWITCH_PRIVATE_CHAT_MSG,true); + } + }); follow_list.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false)); follow_list.setHasFixedSize(true); @@ -202,6 +225,12 @@ public class MsgSettActivity extends AbsActivity { } } + if(SpUtil.getInstance().getBooleanValue(SWITCH_PRIVATE_CHAT_MSG)){ + privateChatMessageSwitch.setImageResource(R.mipmap.special_icon_on); + }else{ + privateChatMessageSwitch.setImageResource(R.mipmap.special_icon_off); + } + MsgFollowAdapter topAdapter = new MsgFollowAdapter(MsgSettActivity.this, data.getFollowList()); follow_list.setAdapter(topAdapter); follow_list.setVisibility(View.VISIBLE); diff --git a/main/src/main/res/layout/activity_msg_sett.xml b/main/src/main/res/layout/activity_msg_sett.xml index fb9409119..19fed35e7 100644 --- a/main/src/main/res/layout/activity_msg_sett.xml +++ b/main/src/main/res/layout/activity_msg_sett.xml @@ -23,6 +23,46 @@ android:layout_marginTop="12dp" android:background="@color/color_white"> + + + + + + + + + + + + +