Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add switch for whether delete messages after existing chat room. #396

Merged
merged 13 commits into from
Aug 28, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
add switch for whether delete messages after existing chat room.
  • Loading branch information
jinanzhuan committed Jul 15, 2020
commit 3210a119a549ac3be15f21fd6aaf25c986366a5d
8 changes: 8 additions & 0 deletions app/src/main/java/com/hyphenate/chatuidemo/DemoModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,14 @@ public boolean isDeleteMessagesAsExitGroup() {
return PreferenceManager.getInstance().isDeleteMessagesAsExitGroup();
}

public void setDeleteMessagesAsExitChatRoom(boolean value) {
PreferenceManager.getInstance().setDeleteMessagesAsExitChatRoom(value);
}

public boolean isDeleteMessagesAsExitChatRoom() {
return PreferenceManager.getInstance().isDeleteMessagesAsExitChatRoom();
}

public void setTransfeFileByUser(boolean value) {
PreferenceManager.getInstance().setTransferFileByUser(value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public class SettingsFragment extends Fragment implements OnClickListener {
private RelativeLayout rl_switch_chatroom_leave;

private RelativeLayout rl_switch_delete_msg_when_exit_group;
private RelativeLayout rl_switch_delete_msg_when_exit_chat_room;
private RelativeLayout rl_set_transfer_file_by_userself;
private RelativeLayout rl_set_autodownload_thumbnail;
private RelativeLayout rl_switch_auto_accept_group_invitation;
Expand Down Expand Up @@ -120,6 +121,7 @@ public class SettingsFragment extends Fragment implements OnClickListener {
private EaseSwitchButton speakerSwitch;
private EaseSwitchButton ownerLeaveSwitch;
private EaseSwitchButton switch_delete_msg_when_exit_group;
private EaseSwitchButton switch_delete_msg_when_exit_chat_room;
private EaseSwitchButton set_transfer_file_by_userself;
private EaseSwitchButton set_autodownload_thumbnail;
private EaseSwitchButton switch_auto_accept_group_invitation;
Expand Down Expand Up @@ -149,6 +151,7 @@ public void onActivityCreated(Bundle savedInstanceState) {
rl_switch_speaker = (RelativeLayout) getView().findViewById(R.id.rl_switch_speaker);
rl_switch_chatroom_leave = (RelativeLayout) getView().findViewById(R.id.rl_switch_chatroom_owner_leave);
rl_switch_delete_msg_when_exit_group = (RelativeLayout) getView().findViewById(R.id.rl_switch_delete_msg_when_exit_group);
rl_switch_delete_msg_when_exit_chat_room = (RelativeLayout) getView().findViewById(R.id.rl_switch_delete_msg_when_exit_chat_room);
rl_set_transfer_file_by_userself = (RelativeLayout) getView().findViewById(R.id.rl_set_transfer_file_by_userself);
rl_set_autodownload_thumbnail = (RelativeLayout) getView().findViewById(R.id.rl_set_autodownload_thumbnail);
rl_switch_auto_accept_group_invitation = (RelativeLayout) getView().findViewById(R.id.rl_switch_auto_accept_group_invitation);
Expand All @@ -172,6 +175,7 @@ public void onActivityCreated(Bundle savedInstanceState) {
speakerSwitch = (EaseSwitchButton) getView().findViewById(R.id.switch_speaker);
ownerLeaveSwitch = (EaseSwitchButton) getView().findViewById(R.id.switch_owner_leave);
switch_delete_msg_when_exit_group = (EaseSwitchButton) getView().findViewById(R.id.switch_delete_msg_when_exit_group);
switch_delete_msg_when_exit_chat_room = (EaseSwitchButton) getView().findViewById(R.id.switch_delete_msg_when_exit_chat_room);
set_transfer_file_by_userself = (EaseSwitchButton) getView().findViewById(R.id.set_transfer_file_by_userself);
set_autodownload_thumbnail = (EaseSwitchButton) getView().findViewById(R.id.set_autodownload_thumbnail);
switch_auto_accept_group_invitation = (EaseSwitchButton) getView().findViewById(R.id.switch_auto_accept_group_invitation);
Expand Down Expand Up @@ -212,6 +216,7 @@ public void onActivityCreated(Bundle savedInstanceState) {
pushNick.setOnClickListener(this);
rl_switch_chatroom_leave.setOnClickListener(this);
rl_switch_delete_msg_when_exit_group.setOnClickListener(this);
rl_switch_delete_msg_when_exit_chat_room.setOnClickListener(this);
rl_set_transfer_file_by_userself.setOnClickListener(this);
rl_set_autodownload_thumbnail.setOnClickListener(this);
rl_switch_auto_accept_group_invitation.setOnClickListener(this);
Expand Down Expand Up @@ -269,6 +274,13 @@ public void onActivityCreated(Bundle savedInstanceState) {
switch_delete_msg_when_exit_group.closeSwitch();
}

// delete messages when exit chat room?
if(settingsModel.isDeleteMessagesAsExitChatRoom()){
switch_delete_msg_when_exit_chat_room.openSwitch();
} else {
switch_delete_msg_when_exit_chat_room.closeSwitch();
}

if(settingsModel.isSetTransferFileByUser()){
set_transfer_file_by_userself.openSwitch();
} else {
Expand Down Expand Up @@ -404,6 +416,17 @@ public void onClick(View v) {
chatOptions.setDeleteMessagesAsExitGroup(true);
}
break;
case R.id.rl_switch_delete_msg_when_exit_chat_room:
if(switch_delete_msg_when_exit_chat_room.isSwitchOpen()){
switch_delete_msg_when_exit_chat_room.closeSwitch();
settingsModel.setDeleteMessagesAsExitChatRoom(false);
chatOptions.setDeleteMessagesAsExitChatRoom(false);
}else{
switch_delete_msg_when_exit_chat_room.openSwitch();
settingsModel.setDeleteMessagesAsExitChatRoom(true);
chatOptions.setDeleteMessagesAsExitChatRoom(true);
}
break;
case R.id.rl_set_transfer_file_by_userself:
if(set_transfer_file_by_userself.isSwitchOpen()){
set_transfer_file_by_userself.closeSwitch();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class PreferenceManager {

private static String SHARED_KEY_SETTING_CHATROOM_OWNER_LEAVE = "shared_key_setting_chatroom_owner_leave";
private static String SHARED_KEY_SETTING_DELETE_MESSAGES_WHEN_EXIT_GROUP = "shared_key_setting_delete_messages_when_exit_group";
private static String SHARED_KEY_SETTING_DELETE_MESSAGES_WHEN_EXIT_CHAT_ROOM = "shared_key_setting_delete_messages_when_exit_chat_room";
private static String SHARED_KEY_SETTING_TRANSFER_FILE_BY_USER = "shared_key_setting_transfer_file_by_user";
private static String SHARED_KEY_SETTING_AUTODOWNLOAD_THUMBNAIL = "shared_key_setting_autodownload_thumbnail";
private static String SHARED_KEY_SETTING_AUTO_ACCEPT_GROUP_INVITATION = "shared_key_setting_auto_accept_group_invitation";
Expand Down Expand Up @@ -153,6 +154,15 @@ public boolean isDeleteMessagesAsExitGroup() {
return mSharedPreferences.getBoolean(SHARED_KEY_SETTING_DELETE_MESSAGES_WHEN_EXIT_GROUP, true);
}

public void setDeleteMessagesAsExitChatRoom(boolean value){
editor.putBoolean(SHARED_KEY_SETTING_DELETE_MESSAGES_WHEN_EXIT_CHAT_ROOM, value);
editor.apply();
}

public boolean isDeleteMessagesAsExitChatRoom() {
return mSharedPreferences.getBoolean(SHARED_KEY_SETTING_DELETE_MESSAGES_WHEN_EXIT_CHAT_ROOM, true);
}

public void setTransferFileByUser(boolean value) {
editor.putBoolean(SHARED_KEY_SETTING_TRANSFER_FILE_BY_USER, value);
editor.apply();
Expand Down
25 changes: 25 additions & 0 deletions app/src/main/res/layout/em_fragment_conversation_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,31 @@
android:layout_centerVertical="true" />
</RelativeLayout>

<RelativeLayout
android:id="@+id/rl_switch_delete_msg_when_exit_chat_room"
android:layout_width="match_parent"
android:layout_height="50dip"
android:background="@drawable/em_btn_bottom_selector"
android:padding="10dip" >

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:paddingLeft="10dip"
android:text="@string/delete_msg_when_exit_chat_room"
android:textColor="@android:color/black"
android:textSize="14sp"
android:typeface="serif" />

<com.hyphenate.easeui.widget.EaseSwitchButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/switch_delete_msg_when_exit_chat_room"
android:layout_alignParentRight="true"
android:layout_centerVertical="true" />
</RelativeLayout>

<RelativeLayout
android:id="@+id/rl_set_transfer_file_by_userself"
android:layout_width="match_parent"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-zh/em_strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@
<string name="join_public_group">加入公开群</string>
<string name="chatroom_allow_owner_leave"> 允许聊天室群主离开</string>
<string name="delete_msg_when_exit_group">退出群组时删除聊天数据</string>
<string name="delete_msg_when_exit_chat_room">退出聊天室时删除聊天数据</string>
<string name="set_transfer_file_by_userself">无需用户实现上传下载</string>
<string name="set_autodownload_thumbnail">是否自动下载缩略图附件</string>
<string name="auto_accept_group_invitation">自动同意群组加群邀请</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/em_strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@
<string name="join_public_group">Join public group</string>
<string name="chatroom_allow_owner_leave">Allow channel owner leave</string>
<string name="delete_msg_when_exit_group">Delete messages when exit group</string>
<string name="delete_msg_when_exit_chat_room">Delete messages when exit chat room</string>
<string name="set_transfer_file_by_userself">No need to implement transfer file function by user</string>
<string name="set_autodownload_thumbnail">Autodownload thumbnail or not</string>
<string name="auto_accept_group_invitation">Auto accept group invitation</string>
Expand Down