Skip to content

Commit

Permalink
revert #3177
Browse files Browse the repository at this point in the history
  • Loading branch information
adbenitez committed Oct 14, 2024
1 parent e5b8e48 commit 25e0068
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ public class ConversationListActivity extends PassphraseRequiredActionBarActivit
public static final String CLEAR_NOTIFICATIONS = "clear_notifications";
public static final String ACCOUNT_ID_EXTRA = "account_id";
public static final String FROM_WELCOME = "from_welcome";
public static final String WARN_CANNOT_ENCRYPT = "warn_cannot_encrypt";

private ConversationListFragment conversationListFragment;
public TextView title;
Expand Down Expand Up @@ -270,11 +269,6 @@ private void refresh() {
AccountManager.getInstance().switchAccountAndStartActivity(this, accountId);
}

String warnAddr = getIntent().getStringExtra(WARN_CANNOT_ENCRYPT);
if (!TextUtils.isEmpty(warnAddr)) {
DcHelper.showEncryptionRequiredDialog(this, warnAddr);
}

refreshAvatar();
refreshUnreadIndicator();
refreshTitle();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,6 @@ public void onContactSelected(int specialId, String addr) {
int contactId = dcContext.lookupContactIdByAddr(addr);
if (contactId!=0 && dcContext.getChatIdByContactId(contactId)!=0) {
openConversation(dcContext.getChatIdByContactId(contactId));
} else if (contactId == 0 && dcContext.isChatmail()) {
DcHelper.showEncryptionRequiredDialog(this, addr);
} else {
String nameNAddr = contactId == 0 ? addr : dcContext.getContact(contactId).getNameNAddr();
new AlertDialog.Builder(this)
Expand Down
20 changes: 6 additions & 14 deletions src/main/java/org/thoughtcrime/securesms/ShareActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -251,26 +251,18 @@ private void handleResolvedMedia(Intent intent) {
}
*/

String addr = null;
if(chatId == -1 && extraEmail != null && extraEmail.length > 0) {
addr = extraEmail[0];
final String addr = extraEmail[0];
int contactId = dcContext.lookupContactIdByAddr(addr);

if(contactId != 0 || !dcContext.isChatmail()) {
if(contactId == 0) {
contactId = dcContext.createContact(null, addr);
}

chatId = dcContext.createChatByContactId(contactId);
addr = null;
if(contactId == 0) {
contactId = dcContext.createContact(null, addr);
}

chatId = dcContext.createChatByContactId(contactId);
}
Intent composeIntent;
if (addr != null) {
composeIntent = new Intent(this, ConversationListActivity.class);
composeIntent.putExtra(ConversationListActivity.WARN_CANNOT_ENCRYPT, addr);
startActivity(composeIntent);
} else if (chatId != -1) {
if (chatId != -1) {
composeIntent = getBaseShareIntent(ConversationActivity.class);
composeIntent.putExtra(ConversationActivity.CHAT_ID_EXTRA, chatId);
RelayUtil.setSharedUris(composeIntent, resolvedExtras);
Expand Down
10 changes: 0 additions & 10 deletions src/main/java/org/thoughtcrime/securesms/connect/DcHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -481,16 +481,6 @@ public static void showInvalidUnencryptedDialog(Context context) {
.show();
}

public static void showEncryptionRequiredDialog(Context context, String addr) {
new AlertDialog.Builder(context)
.setMessage(context.getString(R.string.encryption_required_for_new_contact, addr))
.setNeutralButton(R.string.learn_more, (d, w) -> openHelp(context, "#howtoe2ee"))
.setNegativeButton(R.string.qrscan_title, (d, w) -> context.startActivity(new Intent(context, QrActivity.class)))
.setPositiveButton(R.string.ok, null)
.setCancelable(true)
.show();
}

public static void openHelp(Context context, String section) {
Intent intent = new Intent(context, LocalHelpActivity.class);
if (section != null) { intent.putExtra(LocalHelpActivity.SECTION_EXTRA, section); }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,14 @@ public void onClick(View widget) {
String addr = prepareUrl(url);
Activity activity = (Activity) widget.getContext();
DcContext dcContext = DcHelper.getContext(activity);
int contactId = dcContext.lookupContactIdByAddr(addr);
DcContact contact = (contactId != 0)? dcContext.getContact(contactId) : null;
if (contact != null && !contact.isBlocked() && dcContext.getChatIdByContactId(contactId) != 0) {
DcContact contact = dcContext.getContact(dcContext.createContact(null, addr));
if (contact.getId() != 0 && !contact.isBlocked() && dcContext.getChatIdByContactId(contact.getId()) != 0) {
openChat(activity, contact);
} else if (contact == null && dcContext.isChatmail()) {
DcHelper.showEncryptionRequiredDialog(activity, addr);
} else {
String nameNAddr = contact != null ? contact.getNameNAddr() : addr;
new AlertDialog.Builder(activity)
.setMessage(activity.getString(R.string.ask_start_chat_with, nameNAddr))
.setMessage(activity.getString(R.string.ask_start_chat_with, contact.getNameNAddr()))
.setPositiveButton(android.R.string.ok, (dialog, which) -> {
openChat(activity, contact == null? dcContext.getContact(dcContext.createContact(null, addr)) : contact);
openChat(activity, contact);
})
.setNegativeButton(R.string.cancel, null)
.show();
Expand Down
1 change: 0 additions & 1 deletion src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,6 @@
<string name="chat_protection_broken_explanation">End-to-end encryption cannot be guaranteed anymore, likely because %1$s reinstalled Delta Chat or sent a message from another device.\n\nYou may meet them in person and scan their QR code again to reestablish guaranteed end-to-end encryption.</string>
<string name="invalid_unencrypted_tap_to_learn_more">⚠️ %1$s requires end-to-end encryption which is not setup for this chat yet. Tap to learn more.</string>
<string name="invalid_unencrypted_explanation">To establish end-to-end-encryption, you may meet contacts in person and scan their QR Code to introduce them.</string>
<string name="encryption_required_for_new_contact">End-to-end encryption is required but it is not setup for %1$s yet.\n\nYou may share your invite link with them or meet in person and scan their QR Code.</string>
<string name="learn_more">Learn More</string>

<string name="devicemsg_self_deleted">You deleted the \"Saved messages\" chat.\n\nℹ️ To use the \"Saved messages\" feature again, create a new chat with yourself.</string>
Expand Down

0 comments on commit 25e0068

Please sign in to comment.