mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 12b6939e7e | |||
| 20487d9e96 | |||
| a1920e383a | |||
| 4d3856c012 |
@@ -709,6 +709,25 @@ public class Rpc {
|
||||
transport.call("set_chat_profile_image", mapper.valueToTree(accountId), mapper.valueToTree(chatId), mapper.valueToTree(imagePath));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set group or broadcast channel description.
|
||||
* Sends out #DC_EVENT_CHAT_MODIFIED and #DC_EVENT_MSGS_CHANGED if a status message was sent.
|
||||
* <p>
|
||||
* See also getChatDescription().
|
||||
*/
|
||||
public void setChatDescription(Integer accountId, Integer chatId, String descriptionStr) throws RpcException {
|
||||
transport.call("set_chat_description", mapper.valueToTree(accountId), mapper.valueToTree(chatId), mapper.valueToTree(descriptionStr));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get group or broadcast channel description.
|
||||
* <p>
|
||||
* See also setChatDescription().
|
||||
*/
|
||||
public String getChatDescription(Integer accountId, Integer chatId) throws RpcException {
|
||||
return transport.callForResult(new TypeReference<String>(){}, "get_chat_description", mapper.valueToTree(accountId), mapper.valueToTree(chatId));
|
||||
}
|
||||
|
||||
public void setChatVisibility(Integer accountId, Integer chatId, ChatVisibility visibility) throws RpcException {
|
||||
transport.call("set_chat_visibility", mapper.valueToTree(accountId), mapper.valueToTree(chatId), mapper.valueToTree(visibility));
|
||||
}
|
||||
|
||||
@@ -63,6 +63,7 @@ public class GroupCreateActivity extends PassphraseRequiredActionBarActivity
|
||||
private boolean unencrypted;
|
||||
private boolean broadcast;
|
||||
private EditText groupName;
|
||||
private EditText descriptionText;
|
||||
private ListView lv;
|
||||
private ImageView avatar;
|
||||
private Bitmap avatarBmp;
|
||||
@@ -140,6 +141,7 @@ public class GroupCreateActivity extends PassphraseRequiredActionBarActivity
|
||||
lv = ViewUtil.findById(this, R.id.selected_contacts_list);
|
||||
avatar = ViewUtil.findById(this, R.id.avatar);
|
||||
groupName = ViewUtil.findById(this, R.id.group_name);
|
||||
descriptionText = ViewUtil.findById(this, R.id.description_text);
|
||||
TextView chatHints = ViewUtil.findById(this, R.id.chat_hints);
|
||||
|
||||
// add padding to avoid content hidden behind system bars
|
||||
@@ -174,10 +176,12 @@ public class GroupCreateActivity extends PassphraseRequiredActionBarActivity
|
||||
|
||||
if (broadcast) {
|
||||
groupName.setHint(R.string.channel_name);
|
||||
descriptionText.setHint(R.string.channel_description);
|
||||
chatHints.setVisibility(View.VISIBLE);
|
||||
} else if (unencrypted) {
|
||||
avatar.setVisibility(View.GONE);
|
||||
groupName.setHint(R.string.subject);
|
||||
descriptionText.setVisibility(View.GONE);
|
||||
chatHints.setVisibility(View.GONE);
|
||||
} else {
|
||||
chatHints.setVisibility(View.GONE);
|
||||
@@ -186,6 +190,16 @@ public class GroupCreateActivity extends PassphraseRequiredActionBarActivity
|
||||
if(isEdit()) {
|
||||
groupName.setText(dcContext.getChat(groupChatId).getName());
|
||||
lv.setVisibility(View.GONE);
|
||||
|
||||
// Load existing description
|
||||
try {
|
||||
String description = DcHelper.getRpc(this).getChatDescription(dcContext.getAccountId(), groupChatId);
|
||||
if (description != null && !description.isEmpty()) {
|
||||
descriptionText.setText(description);
|
||||
}
|
||||
} catch (RpcException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -286,6 +300,16 @@ public class GroupCreateActivity extends PassphraseRequiredActionBarActivity
|
||||
AvatarHelper.setGroupAvatar(this, groupChatId, avatarBmp);
|
||||
}
|
||||
|
||||
// Set description if provided
|
||||
String description = getDescription();
|
||||
if (description != null && !description.isEmpty()) {
|
||||
try {
|
||||
DcHelper.getRpc(this).setChatDescription(dcContext.getAccountId(), groupChatId, description);
|
||||
} catch (RpcException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
attachmentManager.cleanup();
|
||||
Intent intent = new Intent(this, ConversationActivity.class);
|
||||
intent.putExtra(ConversationActivity.CHAT_ID_EXTRA, groupChatId);
|
||||
@@ -309,6 +333,14 @@ public class GroupCreateActivity extends PassphraseRequiredActionBarActivity
|
||||
|
||||
if (avatarChanged) AvatarHelper.setGroupAvatar(this, groupChatId, avatarBmp);
|
||||
|
||||
// Update description
|
||||
String description = getDescription();
|
||||
try {
|
||||
DcHelper.getRpc(this).setChatDescription(dcContext.getAccountId(), groupChatId, description != null ? description : "");
|
||||
} catch (RpcException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
attachmentManager.cleanup();
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra(GroupCreateActivity.EDIT_GROUP_CHAT_ID, groupChatId);
|
||||
@@ -322,7 +354,18 @@ public class GroupCreateActivity extends PassphraseRequiredActionBarActivity
|
||||
|
||||
private @Nullable String getGroupName() {
|
||||
String ret = groupName.getText() != null ? groupName.getText().toString() : null;
|
||||
if(ret!=null) {
|
||||
if(ret != null) {
|
||||
ret = ret.trim();
|
||||
if(ret.isEmpty()) {
|
||||
ret = null;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private @Nullable String getDescription() {
|
||||
String ret = descriptionText.getText() != null ? descriptionText.getText().toString() : null;
|
||||
if(ret != null) {
|
||||
ret = ret.trim();
|
||||
if(ret.isEmpty()) {
|
||||
ret = null;
|
||||
|
||||
@@ -30,6 +30,8 @@ import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import chat.delta.rpc.RpcException;
|
||||
|
||||
public class ProfileAdapter extends RecyclerView.Adapter
|
||||
{
|
||||
public static final int ITEM_AVATAR = 10;
|
||||
@@ -278,8 +280,26 @@ public class ProfileAdapter extends RecyclerView.Adapter
|
||||
|
||||
itemData.add(new ItemData(ITEM_AVATAR, null, 0));
|
||||
|
||||
if (isSelfTalk || dcContact != null && !dcContact.getStatus().isEmpty()) {
|
||||
itemDataStatusText = isSelfTalk ? context.getString(R.string.saved_messages_explain) : dcContact.getStatus();
|
||||
// Show status/description for contacts, self-talk, groups, and broadcast channels
|
||||
String statusOrDescription = "";
|
||||
if (isSelfTalk) {
|
||||
statusOrDescription = context.getString(R.string.saved_messages_explain);
|
||||
} else if (dcContact != null && !dcContact.getStatus().isEmpty()) {
|
||||
statusOrDescription = dcContact.getStatus();
|
||||
} else if (dcChat != null && (dcChat.isGroup() || isOutBroadcast)) {
|
||||
// Load group or broadcast channel description
|
||||
try {
|
||||
String description = DcHelper.getRpc(context).getChatDescription(dcContext.getAccountId(), dcChat.getId());
|
||||
if (description != null && !description.isEmpty()) {
|
||||
statusOrDescription = description;
|
||||
}
|
||||
} catch (RpcException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (!statusOrDescription.isEmpty()) {
|
||||
itemDataStatusText = statusOrDescription;
|
||||
itemData.add(new ItemData(ITEM_SIGNATURE, itemDataStatusText, 0));
|
||||
} else {
|
||||
itemData.add(new ItemData(ITEM_DIVIDER, null, 0));
|
||||
|
||||
@@ -39,6 +39,24 @@
|
||||
</androidx.appcompat.widget.AppCompatEditText>
|
||||
</LinearLayout>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/description_text_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginTop="8dp">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatEditText
|
||||
android:id="@+id/description_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="top|start"
|
||||
android:hint="@string/group_description"
|
||||
android:inputType="textMultiLine"
|
||||
android:maxLines="3" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/chat_hints"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -523,6 +523,8 @@
|
||||
<string name="group_create_button">Create Group</string>
|
||||
<string name="group_please_enter_group_name">Please enter a name for the group.</string>
|
||||
<string name="group_add_members">Add Members</string>
|
||||
<string name="group_description">Description</string>
|
||||
<string name="channel_description">Channel Description</string>
|
||||
<string name="group_self_not_in_group">You must be a member of the group to perform this action.</string>
|
||||
<string name="profile_encryption">Encryption</string>
|
||||
<string name="profile_shared_chats">Chats in Common</string>
|
||||
|
||||
Reference in New Issue
Block a user