Merge pull request #3793 from deltachat/adb/pgp-contacts2

adapt to new key-contacts
This commit is contained in:
adb
2025-07-09 21:07:00 +00:00
committed by GitHub
23 changed files with 125 additions and 15 deletions
+4
View File
@@ -10,6 +10,10 @@
* Improve hint for app drafts
* Add Text-To-Speech (TTS) support for in-chat apps
* New icon for the QR icon
* Improved separation between unencryted chats/contacts and encrypted ones, avoiding mixing of encrypted and unencrypted messages in the same chat
* Removed padlocks, as encrypted is the default "normal" state. Instead, unencrypted email is marked with a small email / letter (✉️) icon
* Classic email chats/threads get a big email / letter icon making it easy to recognize
* Update to core 2.0.0
## v1.58.4
2025-05
+12
View File
@@ -1237,6 +1237,12 @@ JNIEXPORT jint Java_com_b44t_messenger_DcChat_getColor(JNIEnv *env, jobject obj)
}
JNIEXPORT jboolean Java_com_b44t_messenger_DcChat_isEncrypted(JNIEnv *env, jobject obj)
{
return dc_chat_is_encrypted(get_dc_chat(env, obj))!=0;
}
JNIEXPORT jboolean Java_com_b44t_messenger_DcChat_isUnpromoted(JNIEnv *env, jobject obj)
{
return dc_chat_is_unpromoted(get_dc_chat(env, obj))!=0;
@@ -1826,6 +1832,12 @@ JNIEXPORT jboolean Java_com_b44t_messenger_DcContact_isVerified(JNIEnv *env, job
}
JNIEXPORT jboolean Java_com_b44t_messenger_DcContact_isKeyContact(JNIEnv *env, jobject obj)
{
return dc_contact_is_key_contact(get_dc_contact(env, obj))==1;
}
JNIEXPORT jint Java_com_b44t_messenger_DcContact_getVerifierId(JNIEnv *env, jobject obj)
{
return dc_contact_get_verifier_id(get_dc_contact(env, obj));
@@ -38,6 +38,7 @@ public class DcChat {
public native String getMailinglistAddr();
public native String getProfileImage ();
public native int getColor ();
public native boolean isEncrypted ();
public native boolean isUnpromoted ();
public native boolean isSelfTalk ();
public native boolean isDeviceTalk ();
@@ -57,6 +57,7 @@ public class DcContact {
public native boolean wasSeenRecently();
public native boolean isBlocked ();
public native boolean isVerified ();
public native boolean isKeyContact ();
public native int getVerifierId ();
public native boolean isBot ();
@@ -173,6 +173,10 @@ public class Rpc {
}
}
public String getMigrationError(int accountId) throws RpcException {
return gson.fromJson(getResult("get_migration_error", accountId), String.class);
}
private static class Response {
public final int id;
public final JsonElement result;
@@ -446,7 +446,10 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
}
if (isMultiUser()) {
if (dcChat.canSend() && !dcChat.isBroadcast() && !dcChat.isMailingList()) {
if (dcChat.isEncrypted()
&& dcChat.canSend()
&& !dcChat.isBroadcast()
&& !dcChat.isMailingList()) {
menu.findItem(R.id.menu_leave).setVisible(true);
}
}
@@ -194,6 +194,8 @@ public class ConversationListActivity extends PassphraseRequiredActionBarActivit
refresh();
if (BuildConfig.DEBUG) checkNdkArchitecture();
DcHelper.maybeShowMigrationError(this);
}
/**
@@ -106,7 +106,7 @@ public class ConversationTitleView extends RelativeLayout {
DcContact dcContact = dcContext.getContact(chatContacts[0]);
if (!profileView && dcContact.isBot()) {
subtitleStr = context.getString(R.string.bot);
} else if (profileView) {
} else if (profileView || !dcChat.isEncrypted()) {
subtitleStr = dcContact.getAddr();
}
isOnline = dcContact.wasSeenRecently();
@@ -107,7 +107,8 @@ public class ProfileActivity extends PassphraseRequiredActionBarActivity
boolean canReceive = true;
if (chatId != 0) {
menu.findItem(R.id.menu_clone).setVisible(chatIsMultiUser && !chatIsMailingList);
DcChat dcChat = dcContext.getChat(chatId);
menu.findItem(R.id.menu_clone).setVisible(chatIsMultiUser && !chatIsMailingList && dcChat.isEncrypted());
if (chatIsDeviceTalk) {
menu.findItem(R.id.edit_name).setVisible(false);
menu.findItem(R.id.show_encr_info).setVisible(false);
@@ -117,8 +118,9 @@ public class ProfileActivity extends PassphraseRequiredActionBarActivity
if (chatIsBroadcast) {
canReceive = false;
} else {
DcChat dcChat = dcContext.getChat(chatId);
if (!chatIsMailingList && !dcChat.canSend()) {
if (!dcChat.isEncrypted()
|| !dcChat.canSend()
|| chatIsMailingList) {
menu.findItem(R.id.edit_name).setVisible(false);
}
}
@@ -311,7 +311,7 @@ public class ProfileAdapter extends RecyclerView.Adapter
if (memberList!=null && !isMailingList) {
itemData.add(new ItemData(ITEM_DIVIDER, null, 0));
if (dcChat != null) {
if (dcChat.canSend()) {
if (dcChat.canSend() && dcChat.isEncrypted()) {
itemData.add(new ItemData(ITEM_MEMBERS, DcContact.DC_CONTACT_ID_ADD_MEMBER, 0));
if (!isBroadcast) {
itemData.add(new ItemData(ITEM_MEMBERS, DcContact.DC_CONTACT_ID_QR_INVITE, 0));
@@ -158,7 +158,7 @@ public class ProfileFragment extends Fragment
if (contactId>DcContact.DC_CONTACT_ID_LAST_SPECIAL || contactId==DcContact.DC_CONTACT_ID_SELF) {
if (actionMode==null) {
DcChat dcChat = dcContext.getChat(chatId);
if (dcChat.canSend()) {
if (dcChat.canSend() && dcChat.isEncrypted()) {
adapter.toggleMemberSelection(contactId);
actionMode = ((AppCompatActivity) requireActivity()).startSupportActionMode(actionModeCallback);
}
@@ -96,6 +96,8 @@ public class WelcomeActivity extends BaseActionBarActivity implements DcEventCen
intent.setAction(DC_REQUEST_ACCOUNT_DATA);
sendBroadcast(intent);
}
DcHelper.maybeShowMigrationError(this);
}
protected void initializeActionBar() {
@@ -22,7 +22,7 @@ public class ConversationItemFooter extends LinearLayout {
private TextView dateView;
private TextView editedView;
private ImageView bookmarkIndicatorView;
private ImageView secureIndicatorView;
private ImageView emailIndicatorView;
private ImageView locationIndicatorView;
private DeliveryStatusView deliveryStatusView;
private Integer textColor = null;
@@ -48,7 +48,7 @@ public class ConversationItemFooter extends LinearLayout {
dateView = findViewById(R.id.footer_date);
editedView = findViewById(R.id.footer_edited);
bookmarkIndicatorView = findViewById(R.id.footer_bookmark_indicator);
secureIndicatorView = findViewById(R.id.footer_secure_indicator);
emailIndicatorView = findViewById(R.id.footer_email_indicator);
locationIndicatorView = findViewById(R.id.footer_location_indicator);
deliveryStatusView = new DeliveryStatusView(findViewById(R.id.delivery_indicator));
@@ -65,7 +65,14 @@ public class ConversationItemFooter extends LinearLayout {
boolean bookmark = messageRecord.getOriginalMsgId() != 0 || messageRecord.getSavedMsgId() != 0;
bookmarkIndicatorView.setVisibility(bookmark ? View.VISIBLE : View.GONE);
editedView.setVisibility(messageRecord.isEdited() ? View.VISIBLE : View.GONE);
secureIndicatorView.setVisibility(messageRecord.isSecure() ? View.VISIBLE : View.GONE);
int downloadState = messageRecord.getDownloadState();
if (messageRecord.isSecure() || downloadState == DcMsg.DC_DOWNLOAD_AVAILABLE || downloadState == DcMsg.DC_DOWNLOAD_FAILURE || downloadState == DcMsg.DC_DOWNLOAD_IN_PROGRESS) {
emailIndicatorView.setVisibility(View.GONE);
} else {
emailIndicatorView.setVisibility(View.VISIBLE);
}
locationIndicatorView.setVisibility(messageRecord.hasLocation() ? View.VISIBLE : View.GONE);
presentDeliveryStatus(messageRecord);
}
@@ -74,7 +81,7 @@ public class ConversationItemFooter extends LinearLayout {
dateView.setTextColor(color);
editedView.setTextColor(color);
bookmarkIndicatorView.setColorFilter(color);
secureIndicatorView.setColorFilter(color);
emailIndicatorView.setColorFilter(color);
locationIndicatorView.setColorFilter(color);
deliveryStatusView.setTint(color);
}
@@ -23,6 +23,7 @@ import com.b44t.messenger.DcContext;
import com.b44t.messenger.DcLot;
import com.b44t.messenger.DcMsg;
import com.b44t.messenger.rpc.Rpc;
import com.b44t.messenger.rpc.RpcException;
import org.thoughtcrime.securesms.ApplicationContext;
import org.thoughtcrime.securesms.BuildConfig;
@@ -36,6 +37,7 @@ import org.thoughtcrime.securesms.qr.QrActivity;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.util.FileUtils;
import org.thoughtcrime.securesms.util.MediaUtil;
import org.thoughtcrime.securesms.util.Util;
import java.io.File;
import java.util.Date;
@@ -495,4 +497,62 @@ public class DcHelper {
if (section != null) { intent.putExtra(LocalHelpActivity.SECTION_EXTRA, section); }
context.startActivity(intent);
}
/**
* For the PGP-Contacts migration, things can go wrong.
* The migration happens when the account is setup, at which point no events can be sent yet.
* So, instead, if something goes wrong, it's returned by getLastError().
* This function shows the error message to the user.
* <p>
* A few releases after the PGP-contacts migration (which happened in 2025-05),
* we can remove this function again.
*/
public static void maybeShowMigrationError(Context context) {
try {
String lastError = DcHelper.getRpc(context).getMigrationError(DcHelper.getContext(context).getAccountId());
if (lastError != null && !lastError.isEmpty()) {
Log.w(TAG, "Opening account failed, trying to share error: " + lastError);
String subject = "Delta Chat failed to update";
String email = "delta@merlinux.eu";
new AlertDialog.Builder(context)
.setMessage(context.getString(R.string.error_x, lastError))
.setNeutralButton(R.string.global_menu_edit_copy_desktop, (d, which) -> {
Util.writeTextToClipboard(context, lastError);
})
.setPositiveButton(R.string.menu_send, (d, which) -> {
Intent sharingIntent = new Intent(
Intent.ACTION_SENDTO, Uri.fromParts(
"mailto", email, null
)
);
sharingIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{email});
sharingIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
sharingIntent.putExtra(Intent.EXTRA_TEXT, lastError);
if (sharingIntent.resolveActivity(context.getPackageManager()) == null) {
Log.w(TAG, "No email client found to send crash report");
sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
sharingIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
sharingIntent.putExtra(Intent.EXTRA_TEXT, lastError);
sharingIntent.putExtra(Intent.EXTRA_EMAIL, email);
}
Intent chooser =
Intent.createChooser(sharingIntent, "Send using...");
chooser.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
chooser.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
context.startActivity(chooser);
})
.setCancelable(false)
.show();
}
} catch (RpcException e) {
e.printStackTrace();
}
}
}
@@ -109,7 +109,7 @@ public class ContactSelectionListItem extends LinearLayout implements RecipientM
this.nameView.setEnabled(true);
this.nameView.setText(name==null? "#" : name);
if (contact != null && contact.isVerified()) {
if (contact != null && contact.isKeyContact()) {
number = null;
}
@@ -80,6 +80,7 @@ public class BackupReceiverFragment extends Fragment implements DcEventCenter.Dc
Log.i(TAG,"DC_EVENT_IMEX_PROGRESS, " + permille);
if (permille == 0) {
DcHelper.maybeShowMigrationError(getTransferActivity());
getTransferActivity().setTransferError("Receiving Error");
} else if (permille < 1000) {
percent = permille/10;
Binary file not shown.

Before

Width:  |  Height:  |  Size: 374 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 298 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 429 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 604 B

@@ -0,0 +1,11 @@
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:height="18sp"
android:width="18sp"
android:viewportHeight="24"
android:viewportWidth="24"
android:tint="#FFFFFF">
<path android:fillColor="@android:color/white" android:pathData="M22,6c0,-1.1 -0.9,-2 -2,-2L4,4c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,6zM20,6l-8,5 -8,-5h16zM20,18L4,18L4,8l8,5 8,-5v10z"/>
</vector>
@@ -19,10 +19,10 @@
/>
<ImageView
android:id="@+id/footer_secure_indicator"
android:id="@+id/footer_email_indicator"
android:layout_width="12sp"
android:layout_height="11sp"
android:src="@drawable/msg_encr_out"
android:src="@drawable/ic_outline_email"
android:visibility="gone"
android:layout_gravity="center_vertical|end"
android:importantForAccessibility="no"