Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Delta Chat Android Changelog

## Unreleased

* Allow to set chat description

## v2.43.0
2026-02

Expand Down
56 changes: 41 additions & 15 deletions src/main/java/org/thoughtcrime/securesms/GroupCreateActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
Expand Down Expand Up @@ -44,12 +45,14 @@
import java.util.ArrayList;
import java.util.Objects;

import chat.delta.rpc.Rpc;
import chat.delta.rpc.RpcException;

public class GroupCreateActivity extends PassphraseRequiredActionBarActivity
implements ItemClickListener
{

private static final String TAG = GroupCreateActivity.class.getSimpleName();
public static final String EDIT_GROUP_CHAT_ID = "edit_group_chat_id";
public static final String CREATE_BROADCAST = "create_broadcast";
public static final String UNENCRYPTED = "unencrypted";
Expand All @@ -63,6 +66,7 @@ public class GroupCreateActivity extends PassphraseRequiredActionBarActivity
private boolean unencrypted;
private boolean broadcast;
private EditText groupName;
private EditText chatDescription;
private ListView lv;
private ImageView avatar;
private Bitmap avatarBmp;
Expand Down Expand Up @@ -140,6 +144,7 @@ private void initializeResources() {
lv = ViewUtil.findById(this, R.id.selected_contacts_list);
avatar = ViewUtil.findById(this, R.id.avatar);
groupName = ViewUtil.findById(this, R.id.group_name);
chatDescription = ViewUtil.findById(this, R.id.chat_description);
TextView chatHints = ViewUtil.findById(this, R.id.chat_hints);

// add padding to avoid content hidden behind system bars
Expand Down Expand Up @@ -178,6 +183,7 @@ private void initializeResources() {
} else if (unencrypted) {
avatar.setVisibility(View.GONE);
groupName.setHint(R.string.subject);
findViewById(R.id.chat_description_container).setVisibility(View.GONE);
chatHints.setVisibility(View.GONE);
} else {
chatHints.setVisibility(View.GONE);
Expand All @@ -186,6 +192,14 @@ private void initializeResources() {
if(isEdit()) {
groupName.setText(dcContext.getChat(groupChatId).getName());
lv.setVisibility(View.GONE);

Rpc rpc = DcHelper.getRpc(this);
try {
String description = rpc.getChatDescription(rpc.getSelectedAccountId(), groupChatId);
chatDescription.setText(description);
} catch (RpcException e) {
Log.e(TAG, "RPC error", e);
}
}
}

Expand Down Expand Up @@ -261,22 +275,22 @@ public void onItemDeleteClick(int contactId) {
}

private void createGroup(String groupName) {
if (broadcast) {
try {
groupChatId = DcHelper.getRpc(this).createBroadcast(dcContext.getAccountId(), groupName);
} catch (RpcException e) {
e.printStackTrace();
return;
}
} else if (unencrypted) {
try {
groupChatId = DcHelper.getRpc(this).createGroupChatUnencrypted(dcContext.getAccountId(), groupName);
} catch (RpcException e) {
e.printStackTrace();
return;
Rpc rpc = DcHelper.getRpc(this);
int accId;
try {
accId = rpc.getSelectedAccountId();
if (broadcast) {
groupChatId = rpc.createBroadcast(accId, groupName);
} else if (unencrypted) {
groupChatId = rpc.createGroupChatUnencrypted(accId, groupName);
} else {
groupChatId = rpc.createGroupChat(accId, groupName, false);
}
} else {
groupChatId = dcContext.createGroupChat(groupName);

rpc.setChatDescription(accId, groupChatId, getChatDescription());
} catch (RpcException e) {
Log.e(TAG, "RPC error", e);
return;
}

for (int contactId : getAdapter().getContacts()) {
Expand Down Expand Up @@ -307,6 +321,14 @@ private void updateGroup(String groupName) {
}
dcContext.setChatName(groupChatId, groupName);

Rpc rpc = DcHelper.getRpc(this);
String description = getChatDescription();
try {
rpc.setChatDescription(rpc.getSelectedAccountId(), groupChatId, description);
} catch (RpcException e) {
Log.e(TAG, "RPC error", e);
}

if (avatarChanged) AvatarHelper.setGroupAvatar(this, groupChatId, avatarBmp);

attachmentManager.cleanup();
Expand All @@ -331,6 +353,10 @@ private SelectedContactsAdapter getAdapter() {
return ret;
}

private @Nullable String getChatDescription() {
return chatDescription.getText() != null ? chatDescription.getText().toString().trim() : "";
}

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
Expand Down
27 changes: 23 additions & 4 deletions src/main/java/org/thoughtcrime/securesms/ProfileAdapter.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.thoughtcrime.securesms;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand Down Expand Up @@ -30,8 +31,13 @@
import java.util.HashSet;
import java.util.Set;

import chat.delta.rpc.Rpc;
import chat.delta.rpc.RpcException;

public class ProfileAdapter extends RecyclerView.Adapter
{
private static final String TAG = ProfileAdapter.class.getSimpleName();

public static final int ITEM_AVATAR = 10;
public static final int ITEM_DIVIDER = 20;
public static final int ITEM_SIGNATURE = 25;
Expand Down Expand Up @@ -195,7 +201,7 @@ else if (holder.itemView instanceof ConversationListItem) {
}
else if(holder.itemView instanceof ProfileStatusItem) {
ProfileStatusItem item = (ProfileStatusItem) holder.itemView;
item.setOnLongClickListener(view -> {clickListener.onStatusLongClicked(); return true;});
item.setOnLongClickListener(view -> {clickListener.onStatusLongClicked(dcContact == null); return true;});
item.set(data.label);
}
else if(holder.itemView instanceof ProfileAvatarItem) {
Expand Down Expand Up @@ -230,7 +236,7 @@ else if(holder.itemView instanceof ProfileTextItem) {

public interface ItemClickListener {
void onSettingsClicked(int settingsId);
void onStatusLongClicked();
void onStatusLongClicked(boolean isMultiUser);
void onSharedChatClicked(int chatId);
void onMemberClicked(int contactId);
void onMemberLongClicked(int contactId);
Expand Down Expand Up @@ -278,8 +284,21 @@ public void changeData(@Nullable int[] memberList, @Nullable DcContact dcContact

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();
if (isSelfTalk) {
itemDataStatusText = context.getString(R.string.saved_messages_explain);
} else if (dcContact != null) {
itemDataStatusText = dcContact.getStatus();
} else if (dcChat != null && dcChat.isEncrypted()) {
// Load group or channel description
try {
Rpc rpc = DcHelper.getRpc(context);
itemDataStatusText = rpc.getChatDescription(rpc.getSelectedAccountId(), dcChat.getId());
} catch (RpcException e) {
Log.e(TAG, "RPC error", e);
}
}

if (!itemDataStatusText.isEmpty()) {
itemData.add(new ItemData(ITEM_SIGNATURE, itemDataStatusText, 0));
} else {
itemData.add(new ItemData(ITEM_DIVIDER, null, 0));
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/thoughtcrime/securesms/ProfileFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,10 @@ public void onSettingsClicked(int settingsId) {
}

@Override
public void onStatusLongClicked() {
public void onStatusLongClicked(boolean isMultiUser) {
Context context = requireContext();
new AlertDialog.Builder(context)
.setTitle(R.string.pref_default_status_label)
.setTitle(isMultiUser? R.string.chat_description : R.string.pref_default_status_label)
.setItems(new CharSequence[]{
context.getString(R.string.menu_copy_to_clipboard)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ public static void setStockTranslations(Context context) {
dcContext.setStockTranslation(233, context.getString(R.string.outgoing_video_call));
dcContext.setStockTranslation(234, context.getString(R.string.incoming_audio_call));
dcContext.setStockTranslation(235, context.getString(R.string.incoming_video_call));
dcContext.setStockTranslation(240, context.getString(R.string.chat_description_changed_by_you));
dcContext.setStockTranslation(241, context.getString(R.string.chat_description_changed_by_other));
}

public static File getImexDir() {
Expand Down
18 changes: 18 additions & 0 deletions src/main/res/layout/group_create_activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,24 @@
</androidx.appcompat.widget.AppCompatEditText>
</LinearLayout>

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/chat_description_container"
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/chat_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="top|start"
android:hint="@string/chat_description"
android:inputType="textMultiLine"
android:maxLines="3" />
</com.google.android.material.textfield.TextInputLayout>

<TextView
android:id="@+id/chat_hints"
android:layout_width="match_parent"
Expand Down
4 changes: 4 additions & 0 deletions src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,7 @@
<string name="pref_your_name">Your Name</string>
<!-- Label of the Bio/Signature/Status/Motto field -->
<string name="pref_default_status_label">Bio</string>
<string name="chat_description">Description</string>
<!-- Option name for changing behaviour of the "Enter key" to sending out a message directly (instead of adding new line). If in doubt, please refer to a similar option in other messengers. -->
<string name="pref_enter_sends">Enter Key Sends</string>
<string name="pref_enter_sends_explain">Pressing the Enter key will send text messages</string>
Expand Down Expand Up @@ -889,6 +890,9 @@
<string name="group_image_changed_by_you">You changed the group image.</string>
<!-- %1$s will be replaced by name of the contact who did the action -->
<string name="group_image_changed_by_other">Group image changed by %1$s.</string>
<string name="chat_description_changed_by_you">You changed the chat description.</string>
<!-- %1$s will be replaced by name of the contact who did the action -->
<string name="chat_description_changed_by_other">Chat description changed by %1$s.</string>
<!-- %1$s will be replaced by name of the contact added to the group -->
<string name="member_x_added">Member %1$s added.</string>
<!-- %1$s will be replaced by name of the contact added to the group -->
Expand Down
Loading