mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
adapt to new PGP-contacts
This commit is contained in:
@@ -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 ();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -194,6 +194,8 @@ public class ConversationListActivity extends PassphraseRequiredActionBarActivit
|
||||
refresh();
|
||||
|
||||
if (BuildConfig.DEBUG) checkNdkArchitecture();
|
||||
|
||||
DcHelper.maybeShowMigrationError(this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -292,7 +292,7 @@ public class ProfileSettingsAdapter extends RecyclerView.Adapter
|
||||
|
||||
if (dcChat.isMailingList()) {
|
||||
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));
|
||||
if (!isBroadcast) {
|
||||
itemData.add(new ItemData(ItemData.CATEGORY_MEMBERS, DcContact.DC_CONTACT_ID_QR_INVITE, 0));
|
||||
|
||||
@@ -166,7 +166,7 @@ public class ProfileSettingsFragment 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,7 @@ 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);
|
||||
emailIndicatorView.setVisibility(messageRecord.isSecure() ? View.GONE : View.VISIBLE);
|
||||
locationIndicatorView.setVisibility(messageRecord.hasLocation() ? View.VISIBLE : View.GONE);
|
||||
presentDeliveryStatus(messageRecord);
|
||||
}
|
||||
@@ -74,7 +74,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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user