mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
Merge pull request #4214 from deltachat/adb/chat-description
allow to set chat description
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
# Delta Chat Android Changelog
|
||||
|
||||
## Unreleased
|
||||
|
||||
* Allow to set chat description
|
||||
|
||||
## v2.43.0
|
||||
2026-02
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import android.graphics.Bitmap;
|
||||
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;
|
||||
@@ -44,12 +45,14 @@ import java.io.File;
|
||||
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";
|
||||
@@ -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;
|
||||
@@ -140,6 +144,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);
|
||||
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
|
||||
@@ -178,6 +183,7 @@ public class GroupCreateActivity extends PassphraseRequiredActionBarActivity
|
||||
} 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);
|
||||
@@ -186,6 +192,14 @@ public class GroupCreateActivity extends PassphraseRequiredActionBarActivity
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -261,22 +275,22 @@ public class GroupCreateActivity extends PassphraseRequiredActionBarActivity
|
||||
}
|
||||
|
||||
private void createGroup(String groupName) {
|
||||
if (broadcast) {
|
||||
try {
|
||||
groupChatId = DcHelper.getRpc(this).createBroadcast(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 if (unencrypted) {
|
||||
try {
|
||||
groupChatId = DcHelper.getRpc(this).createGroupChatUnencrypted(dcContext.getAccountId(), groupName);
|
||||
} catch (RpcException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
} 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()) {
|
||||
@@ -307,6 +321,14 @@ public class GroupCreateActivity extends PassphraseRequiredActionBarActivity
|
||||
}
|
||||
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();
|
||||
@@ -331,6 +353,10 @@ public class GroupCreateActivity extends PassphraseRequiredActionBarActivity
|
||||
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);
|
||||
|
||||
@@ -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;
|
||||
@@ -30,8 +31,13 @@ import java.util.Collections;
|
||||
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;
|
||||
@@ -195,7 +201,7 @@ public class ProfileAdapter extends RecyclerView.Adapter
|
||||
}
|
||||
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) {
|
||||
@@ -230,7 +236,7 @@ public class ProfileAdapter extends RecyclerView.Adapter
|
||||
|
||||
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);
|
||||
@@ -278,8 +284,21 @@ 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();
|
||||
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));
|
||||
|
||||
@@ -140,10 +140,10 @@ public class ProfileFragment extends Fragment
|
||||
}
|
||||
|
||||
@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)
|
||||
},
|
||||
|
||||
@@ -225,6 +225,8 @@ public class DcHelper {
|
||||
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() {
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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>
|
||||
@@ -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 -->
|
||||
|
||||
Reference in New Issue
Block a user