adapt to new PGP-contacts

This commit is contained in:
adbenitez 2025-06-24 17:46:51 +02:00
parent bd3c4f9186
commit 966d8784f3
17 changed files with 96 additions and 9 deletions

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) JNIEXPORT jboolean Java_com_b44t_messenger_DcChat_isUnpromoted(JNIEnv *env, jobject obj)
{ {
return dc_chat_is_unpromoted(get_dc_chat(env, obj))!=0; return dc_chat_is_unpromoted(get_dc_chat(env, obj))!=0;

@ -1 +1 @@
Subproject commit 47b9bfc8bf807ad099d2211a59d6ba80290b0c95 Subproject commit c0cf4e7e9b70c9d2201a1e30e5a0e782859ab95b

View file

@ -38,6 +38,7 @@ public class DcChat {
public native String getMailinglistAddr(); public native String getMailinglistAddr();
public native String getProfileImage (); public native String getProfileImage ();
public native int getColor (); public native int getColor ();
public native boolean isEncrypted ();
public native boolean isUnpromoted (); public native boolean isUnpromoted ();
public native boolean isSelfTalk (); public native boolean isSelfTalk ();
public native boolean isDeviceTalk (); public native boolean isDeviceTalk ();

View file

@ -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 { private static class Response {
public final int id; public final int id;
public final JsonElement result; public final JsonElement result;

View file

@ -194,6 +194,8 @@ public class ConversationListActivity extends PassphraseRequiredActionBarActivit
refresh(); refresh();
if (BuildConfig.DEBUG) checkNdkArchitecture(); if (BuildConfig.DEBUG) checkNdkArchitecture();
DcHelper.maybeShowMigrationError(this);
} }
/** /**

View file

@ -292,7 +292,7 @@ public class ProfileSettingsAdapter extends RecyclerView.Adapter
if (dcChat.isMailingList()) { if (dcChat.isMailingList()) {
isMailingList = true; isMailingList = true;
} else if (dcChat.canSend()) { } else if (dcChat.canSend() && dcChat.isEncrypted()) {
itemData.add(new ItemData(ItemData.CATEGORY_MEMBERS, DcContact.DC_CONTACT_ID_ADD_MEMBER, 0)); itemData.add(new ItemData(ItemData.CATEGORY_MEMBERS, DcContact.DC_CONTACT_ID_ADD_MEMBER, 0));
if (!isBroadcast) { if (!isBroadcast) {
itemData.add(new ItemData(ItemData.CATEGORY_MEMBERS, DcContact.DC_CONTACT_ID_QR_INVITE, 0)); itemData.add(new ItemData(ItemData.CATEGORY_MEMBERS, DcContact.DC_CONTACT_ID_QR_INVITE, 0));

View file

@ -166,7 +166,7 @@ public class ProfileSettingsFragment extends Fragment
if (contactId>DcContact.DC_CONTACT_ID_LAST_SPECIAL || contactId==DcContact.DC_CONTACT_ID_SELF) { if (contactId>DcContact.DC_CONTACT_ID_LAST_SPECIAL || contactId==DcContact.DC_CONTACT_ID_SELF) {
if (actionMode==null) { if (actionMode==null) {
DcChat dcChat = dcContext.getChat(chatId); DcChat dcChat = dcContext.getChat(chatId);
if (dcChat.canSend()) { if (dcChat.canSend() && dcChat.isEncrypted()) {
adapter.toggleMemberSelection(contactId); adapter.toggleMemberSelection(contactId);
actionMode = ((AppCompatActivity) requireActivity()).startSupportActionMode(actionModeCallback); actionMode = ((AppCompatActivity) requireActivity()).startSupportActionMode(actionModeCallback);
} }

View file

@ -96,6 +96,8 @@ public class WelcomeActivity extends BaseActionBarActivity implements DcEventCen
intent.setAction(DC_REQUEST_ACCOUNT_DATA); intent.setAction(DC_REQUEST_ACCOUNT_DATA);
sendBroadcast(intent); sendBroadcast(intent);
} }
DcHelper.maybeShowMigrationError(this);
} }
protected void initializeActionBar() { protected void initializeActionBar() {

View file

@ -22,7 +22,7 @@ public class ConversationItemFooter extends LinearLayout {
private TextView dateView; private TextView dateView;
private TextView editedView; private TextView editedView;
private ImageView bookmarkIndicatorView; private ImageView bookmarkIndicatorView;
private ImageView secureIndicatorView; private ImageView emailIndicatorView;
private ImageView locationIndicatorView; private ImageView locationIndicatorView;
private DeliveryStatusView deliveryStatusView; private DeliveryStatusView deliveryStatusView;
private Integer textColor = null; private Integer textColor = null;
@ -48,7 +48,7 @@ public class ConversationItemFooter extends LinearLayout {
dateView = findViewById(R.id.footer_date); dateView = findViewById(R.id.footer_date);
editedView = findViewById(R.id.footer_edited); editedView = findViewById(R.id.footer_edited);
bookmarkIndicatorView = findViewById(R.id.footer_bookmark_indicator); 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); locationIndicatorView = findViewById(R.id.footer_location_indicator);
deliveryStatusView = new DeliveryStatusView(findViewById(R.id.delivery_indicator)); deliveryStatusView = new DeliveryStatusView(findViewById(R.id.delivery_indicator));
@ -65,7 +65,7 @@ public class ConversationItemFooter extends LinearLayout {
boolean bookmark = messageRecord.getOriginalMsgId() != 0 || messageRecord.getSavedMsgId() != 0; boolean bookmark = messageRecord.getOriginalMsgId() != 0 || messageRecord.getSavedMsgId() != 0;
bookmarkIndicatorView.setVisibility(bookmark ? View.VISIBLE : View.GONE); bookmarkIndicatorView.setVisibility(bookmark ? View.VISIBLE : View.GONE);
editedView.setVisibility(messageRecord.isEdited() ? View.VISIBLE : View.GONE); editedView.setVisibility(messageRecord.isEdited() ? View.VISIBLE : View.GONE);
secureIndicatorView.setVisibility(messageRecord.isSecure() ? View.VISIBLE : View.GONE); emailIndicatorView.setVisibility(messageRecord.isSecure() ? View.GONE : View.VISIBLE);
locationIndicatorView.setVisibility(messageRecord.hasLocation() ? View.VISIBLE : View.GONE); locationIndicatorView.setVisibility(messageRecord.hasLocation() ? View.VISIBLE : View.GONE);
presentDeliveryStatus(messageRecord); presentDeliveryStatus(messageRecord);
} }
@ -74,7 +74,7 @@ public class ConversationItemFooter extends LinearLayout {
dateView.setTextColor(color); dateView.setTextColor(color);
editedView.setTextColor(color); editedView.setTextColor(color);
bookmarkIndicatorView.setColorFilter(color); bookmarkIndicatorView.setColorFilter(color);
secureIndicatorView.setColorFilter(color); emailIndicatorView.setColorFilter(color);
locationIndicatorView.setColorFilter(color); locationIndicatorView.setColorFilter(color);
deliveryStatusView.setTint(color); deliveryStatusView.setTint(color);
} }

View file

@ -23,6 +23,7 @@ import com.b44t.messenger.DcContext;
import com.b44t.messenger.DcLot; import com.b44t.messenger.DcLot;
import com.b44t.messenger.DcMsg; import com.b44t.messenger.DcMsg;
import com.b44t.messenger.rpc.Rpc; import com.b44t.messenger.rpc.Rpc;
import com.b44t.messenger.rpc.RpcException;
import org.thoughtcrime.securesms.ApplicationContext; import org.thoughtcrime.securesms.ApplicationContext;
import org.thoughtcrime.securesms.BuildConfig; 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.recipients.Recipient;
import org.thoughtcrime.securesms.util.FileUtils; import org.thoughtcrime.securesms.util.FileUtils;
import org.thoughtcrime.securesms.util.MediaUtil; import org.thoughtcrime.securesms.util.MediaUtil;
import org.thoughtcrime.securesms.util.Util;
import java.io.File; import java.io.File;
import java.util.Date; import java.util.Date;
@ -495,4 +497,62 @@ public class DcHelper {
if (section != null) { intent.putExtra(LocalHelpActivity.SECTION_EXTRA, section); } if (section != null) { intent.putExtra(LocalHelpActivity.SECTION_EXTRA, section); }
context.startActivity(intent); 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();
}
}
} }

View file

@ -80,6 +80,7 @@ public class BackupReceiverFragment extends Fragment implements DcEventCenter.Dc
Log.i(TAG,"DC_EVENT_IMEX_PROGRESS, " + permille); Log.i(TAG,"DC_EVENT_IMEX_PROGRESS, " + permille);
if (permille == 0) { if (permille == 0) {
DcHelper.maybeShowMigrationError(getTransferActivity());
getTransferActivity().setTransferError("Receiving Error"); getTransferActivity().setTransferError("Receiving Error");
} else if (permille < 1000) { } else if (permille < 1000) {
percent = permille/10; 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

View file

@ -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>

View file

@ -19,10 +19,10 @@
/> />
<ImageView <ImageView
android:id="@+id/footer_secure_indicator" android:id="@+id/footer_email_indicator"
android:layout_width="12sp" android:layout_width="12sp"
android:layout_height="11sp" android:layout_height="11sp"
android:src="@drawable/msg_encr_out" android:src="@drawable/ic_outline_email"
android:visibility="gone" android:visibility="gone"
android:layout_gravity="center_vertical|end" android:layout_gravity="center_vertical|end"
android:importantForAccessibility="no" android:importantForAccessibility="no"