mirror of
https://github.com/deltachat/deltachat-android.git
synced 2025-10-03 17:59:39 +02:00
Show channels in a proper "Channel" chat (#3783)
* Rename "broadcast list" to "channel"/"broadcast channel" both in UI and code * feat: Add new channel types * Update CHANGELOG.md * adb's review * refactor: Rename BroadcastChannel to Broadcast * Revert accidental change * Make it possible to leave channels - In a chat, if the chat is an InBroadcast, and it's not a contact request, then the `Leave` menu option is shown with the translated stock string `menu_leave_channel` as its label. - If the user clicks on it, the confirmation dialog has `menu_leave_channel` (rather than `menu_leave_group`) as its positive option. Counterpart of https://github.com/chatmail/core/pull/6984. --------- Co-authored-by: adbenitez <asieldbenitez@gmail.com> Co-authored-by: adb <adb@merlinux.eu>
This commit is contained in:
parent
23d521beed
commit
717777f628
23 changed files with 102 additions and 55 deletions
|
@ -23,6 +23,7 @@ import androidx.loader.app.LoaderManager;
|
|||
import com.b44t.messenger.DcChat;
|
||||
import com.b44t.messenger.DcContact;
|
||||
import com.b44t.messenger.DcContext;
|
||||
import com.b44t.messenger.rpc.RpcException;
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
||||
import com.bumptech.glide.request.target.CustomTarget;
|
||||
import com.bumptech.glide.request.transition.Transition;
|
||||
|
@ -48,7 +49,7 @@ public class GroupCreateActivity extends PassphraseRequiredActionBarActivity
|
|||
{
|
||||
|
||||
public static final String EDIT_GROUP_CHAT_ID = "edit_group_chat_id";
|
||||
public static final String CREATE_BROADCAST = "group_create_broadcast";
|
||||
public static final String CREATE_BROADCAST = "create_broadcast";
|
||||
public static final String CLONE_CHAT_EXTRA = "clone_chat";
|
||||
|
||||
private static final int PICK_CONTACT = 1;
|
||||
|
@ -58,7 +59,7 @@ public class GroupCreateActivity extends PassphraseRequiredActionBarActivity
|
|||
private DcContext dcContext;
|
||||
|
||||
private boolean verified;
|
||||
private boolean broadcast;
|
||||
private boolean broadcast;
|
||||
private EditText groupName;
|
||||
private ListView lv;
|
||||
private ImageView avatar;
|
||||
|
@ -88,12 +89,12 @@ public class GroupCreateActivity extends PassphraseRequiredActionBarActivity
|
|||
isEdit = true;
|
||||
DcChat dcChat = dcContext.getChat(groupChatId);
|
||||
verified = dcChat.isProtected();
|
||||
broadcast = dcChat.isBroadcast();
|
||||
broadcast = dcChat.isOutBroadcast();
|
||||
}
|
||||
|
||||
int chatId = getIntent().getIntExtra(CLONE_CHAT_EXTRA, 0);
|
||||
if (chatId != 0) {
|
||||
broadcast = dcContext.getChat(chatId).isBroadcast();
|
||||
broadcast = dcContext.getChat(chatId).isOutBroadcast();
|
||||
}
|
||||
|
||||
initializeResources();
|
||||
|
@ -120,7 +121,7 @@ public class GroupCreateActivity extends PassphraseRequiredActionBarActivity
|
|||
title = getString(R.string.global_menu_edit_desktop);
|
||||
}
|
||||
else if(broadcast) {
|
||||
title = getString(R.string.new_broadcast_list);
|
||||
title = getString(R.string.new_channel);
|
||||
}
|
||||
else {
|
||||
title = getString(R.string.menu_new_group);
|
||||
|
@ -160,9 +161,8 @@ public class GroupCreateActivity extends PassphraseRequiredActionBarActivity
|
|||
}
|
||||
|
||||
if (broadcast) {
|
||||
avatar.setVisibility(View.GONE);
|
||||
groupName.setHint(R.string.broadcast_list_name);
|
||||
chatHints.setVisibility(isEdit()? View.GONE : View.VISIBLE);
|
||||
groupName.setHint(R.string.channel_name);
|
||||
chatHints.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
chatHints.setVisibility(View.GONE);
|
||||
}
|
||||
|
@ -257,8 +257,12 @@ public class GroupCreateActivity extends PassphraseRequiredActionBarActivity
|
|||
|
||||
private void createGroup(String groupName) {
|
||||
if (broadcast) {
|
||||
groupChatId = dcContext.createBroadcastList();
|
||||
dcContext.setChatName(groupChatId, groupName);
|
||||
try {
|
||||
groupChatId = DcHelper.getRpc(this).createBroadcast(dcContext.getAccountId(), groupName);
|
||||
} catch (RpcException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
groupChatId = dcContext.createGroupChat(verified, groupName);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue