Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
adbenitez committed Oct 27, 2024
2 parents 91f8ce7 + 021a98c commit 7a738ab
Show file tree
Hide file tree
Showing 28 changed files with 1,008 additions and 713 deletions.
10 changes: 10 additions & 0 deletions jni/dc_wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,16 @@ JNIEXPORT jstring Java_com_b44t_messenger_DcContext_getSecurejoinQrSvg(JNIEnv *e
return ret;
}

JNIEXPORT jstring Java_com_b44t_messenger_DcContext_createQrSvg(JNIEnv *env, jobject obj, jstring payload)
{
CHAR_REF(payload);
char* temp = dc_create_qr_svg(payloadPtr);
jstring ret = JSTRING_NEW(temp);
dc_str_unref(temp);
CHAR_UNREF(payload);
return ret;
}

JNIEXPORT jint Java_com_b44t_messenger_DcContext_joinSecurejoin(JNIEnv *env, jobject obj, jstring qr)
{
CHAR_REF(qr);
Expand Down
2 changes: 1 addition & 1 deletion jni/deltachat-core-rust
Submodule deltachat-core-rust updated 66 files
+4 −4 .github/workflows/ci.yml
+92 −0 CHANGELOG.md
+1 −1 CMakeLists.txt
+51 −9 Cargo.lock
+4 −4 Cargo.toml
+12 −0 assets/qr_overlay_delta.svg-part
+1 −1 deltachat-ffi/Cargo.toml
+46 −2 deltachat-ffi/deltachat.h
+37 −1 deltachat-ffi/src/lib.rs
+1 −1 deltachat-jsonrpc/Cargo.toml
+6 −2 deltachat-jsonrpc/src/api.rs
+27 −0 deltachat-jsonrpc/src/api/types/events.rs
+6 −9 deltachat-jsonrpc/src/api/types/message.rs
+1 −1 deltachat-jsonrpc/typescript/package.json
+2 −1 deltachat-repl/Cargo.toml
+10 −8 deltachat-repl/src/cmdline.rs
+3 −9 deltachat-repl/src/main.rs
+1 −1 deltachat-rpc-client/pyproject.toml
+30 −18 deltachat-rpc-client/tests/test_securejoin.py
+1 −1 deltachat-rpc-server/Cargo.toml
+1 −1 deltachat-rpc-server/npm-package/package.json
+12 −12 flake.lock
+2 −0 node/constants.js
+2 −0 node/events.js
+4 −0 node/lib/constants.ts
+1 −1 package.json
+1 −1 python/pyproject.toml
+1 −1 python/src/deltachat/chat.py
+1 −1 release-date.in
+1 −1 scripts/coredeps/install-rust.sh
+1 −1 src/blob.rs
+108 −52 src/chat.rs
+4 −0 src/config.rs
+3 −1 src/constants.rs
+6 −0 src/context.rs
+1 −1 src/decrypt.rs
+3 −1 src/download.rs
+20 −0 src/events/payload.rs
+19 −2 src/imap.rs
+4 −0 src/imap/capabilities.rs
+14 −10 src/imap/client.rs
+3 −17 src/message.rs
+11 −2 src/mimefactory.rs
+8 −0 src/net.rs
+289 −26 src/net/dns.rs
+5 −0 src/net/session.rs
+18 −2 src/peer_channels.rs
+73 −22 src/peerstate.rs
+2 −2 src/pgp.rs
+79 −0 src/qr_code_generator.rs
+2 −1 src/quota.rs
+54 −5 src/reaction.rs
+16 −3 src/receive_imf.rs
+30 −0 src/receive_imf/tests.rs
+17 −34 src/securejoin.rs
+2 −1 src/securejoin/bob.rs
+1 −1 src/securejoin/bobstate.rs
+1 −0 src/smtp/connect.rs
+132 −84 src/sql.rs
+24 −0 src/sql/migrations.rs
+106 −17 src/sql/pool.rs
+18 −0 src/test_utils.rs
+40 −0 src/tests/verified_chats.rs
+5 −5 src/timesmearing.rs
+5 −0 test-data/golden/receive_imf_older_message_from_2nd_device
+7 −0 test-data/golden/verified_chats_message_from_old_dc_setup
1,185 changes: 610 additions & 575 deletions src/main/assets/help/ru/help.html

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/main/java/com/b44t/messenger/DcContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ protected void finalize() throws Throwable {
public DcLot checkQr (String qr) { return new DcLot(checkQrCPtr(qr)); }
public native String getSecurejoinQr (int chat_id);
public native String getSecurejoinQrSvg (int chat_id);
public native String createQrSvg (String payload);
public native int joinSecurejoin (String qr);
public native void sendLocationsToChat (int chat_id, int seconds);
public native boolean isSendingLocationsToChat(int chat_id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import androidx.annotation.NonNull;
Expand Down Expand Up @@ -37,6 +38,7 @@
import org.thoughtcrime.securesms.util.ViewUtil;

import static com.b44t.messenger.DcContact.DC_CONTACT_ID_ADD_ACCOUNT;
import static org.thoughtcrime.securesms.connect.DcHelper.CONFIG_PRIVATE_TAG;

public class AccountSelectionListFragment extends DialogFragment implements DcEventCenter.DcEventDelegate
{
Expand Down Expand Up @@ -134,9 +136,36 @@ private void onContextItemSelected(MenuItem item, int accountId) {
case R.id.menu_mute_notifications:
onToggleMute(accountId);
break;
case R.id.menu_set_tag:
onSetTag(accountId);
break;
}
}

private void onSetTag(int accountId) {
Activity activity = getActivity();
if (activity == null) return;
AccountSelectionListFragment.this.dismiss();

DcContext dcContext = DcHelper.getAccounts(activity).getAccount(accountId);
View view = View.inflate(activity, R.layout.single_line_input, null);
EditText inputField = view.findViewById(R.id.input_field);
inputField.setHint(R.string.profile_tag_hint);
inputField.setText(dcContext.getConfig(CONFIG_PRIVATE_TAG));

new AlertDialog.Builder(activity)
.setTitle(R.string.profile_tag)
.setMessage(R.string.profile_tag_explain)
.setView(view)
.setPositiveButton(android.R.string.ok, (d, b) -> {
String newTag = inputField.getText().toString().trim();
dcContext.setConfig(CONFIG_PRIVATE_TAG, newTag);
AccountManager.getInstance().showSwitchAccountMenu(activity);
})
.setNegativeButton(R.string.cancel, (d, b) -> AccountManager.getInstance().showSwitchAccountMenu(activity))
.show();
}

private void onDeleteAccount(int accountId) {
Activity activity = getActivity();
AccountSelectionListFragment.this.dismiss();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package org.thoughtcrime.securesms.accounts;

import static org.thoughtcrime.securesms.connect.DcHelper.CONFIG_DISPLAY_NAME;
import static org.thoughtcrime.securesms.connect.DcHelper.CONFIG_PRIVATE_TAG;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Color;
Expand Down Expand Up @@ -29,7 +32,7 @@ public class AccountSelectionListItem extends LinearLayout {

private AvatarView contactPhotoImage;
private View addrContainer;
private TextView addrView;
private TextView addrOrTagView;
private TextView nameView;
private ImageView unreadIndicator;
private SwitchCompat enableSwitch;
Expand All @@ -50,7 +53,7 @@ protected void onFinishInflate() {
super.onFinishInflate();
this.contactPhotoImage = findViewById(R.id.contact_photo_image);
this.addrContainer = findViewById(R.id.addr_container);
this.addrView = findViewById(R.id.addr);
this.addrOrTagView = findViewById(R.id.addr_or_tag);
this.nameView = findViewById(R.id.name);
this.unreadIndicator = findViewById(R.id.unread_indicator);
this.enableSwitch = findViewById(R.id.enable_switch);
Expand All @@ -66,7 +69,7 @@ public void bind(@NonNull GlideRequests glideRequests, int accountId, DcContext
this.dcContext = dcContext;
DcContact self = null;
String name;
String addr = null;
String addrOrTag = null;
int unreadCount = 0;
boolean isMuted = dcContext.isMuted();

Expand All @@ -78,15 +81,20 @@ public void bind(@NonNull GlideRequests glideRequests, int accountId, DcContext
this.contactPhotoImage.setSeenRecently(false); // hide connectivity dot
} else {
self = dcContext.getContact(DcContact.DC_CONTACT_ID_SELF);
name = dcContext.getConfig("displayname");
name = dcContext.getConfig(CONFIG_DISPLAY_NAME);
if (TextUtils.isEmpty(name)) {
name = self.getAddr();
}
if (dcContext.isCommunity()) {
addr = getContext().getString(R.string.community);
} else if (!dcContext.isChatmail()) {
addr = self.getAddr();

addrOrTag = dcContext.getConfig(CONFIG_PRIVATE_TAG);
if ("".equals(addrOrTag)) {
if (dcContext.isCommunity()) {
addrOrTag = getContext().getString(R.string.community);
} else if (!dcContext.isChatmail()) {
addrOrTag = self.getAddr();
}
}

unreadCount = dcContext.getFreshMsgs().length;

enableSwitch.setChecked(dcContext.isEnabled());
Expand All @@ -100,15 +108,15 @@ public void bind(@NonNull GlideRequests glideRequests, int accountId, DcContext

setSelected(selected);
if (selected) {
addrView.setTypeface(null, Typeface.BOLD);
addrOrTagView.setTypeface(null, Typeface.BOLD);
nameView.setTypeface(null, Typeface.BOLD);
} else {
addrView.setTypeface(null, Typeface.NORMAL);
addrOrTagView.setTypeface(null, Typeface.NORMAL);
nameView.setTypeface(null, Typeface.NORMAL);
}

updateUnreadIndicator(unreadCount, isMuted);
setText(name, addr);
setText(name, addrOrTag);

if (accountId != DcContact.DC_CONTACT_ID_ADD_ACCOUNT) {
fragment.registerForContextMenu(this);
Expand Down Expand Up @@ -146,11 +154,11 @@ private void updateUnreadIndicator(int unreadCount, boolean isMuted) {
}
}

private void setText(String name, String addr) {
private void setText(String name, String addrOrTag) {
this.nameView.setText(name==null? "#" : name);

if(addr != null) {
this.addrView.setText(addr);
if(!TextUtils.isEmpty(addrOrTag)) {
this.addrOrTagView.setText(addrOrTag);
this.addrContainer.setVisibility(View.VISIBLE);
} else {
this.addrContainer.setVisibility(View.GONE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public class DcHelper {
public static final String CONFIG_PROXY_URL = "proxy_url";
public static final String CONFIG_VERIFIED_ONE_ON_ONE_CHATS = "verified_one_on_one_chats";
public static final String CONFIG_WEBXDC_REALTIME_ENABLED = "webxdc_realtime_enabled";
public static final String CONFIG_PRIVATE_TAG = "private_tag";

public static DcContext getContext(@NonNull Context context) {
return ApplicationContext.getInstance(context).dcContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
import com.b44t.messenger.DcContext;
import com.b44t.messenger.DcEvent;
import com.b44t.messenger.DcLot;
import com.caverock.androidsvg.SVG;
import com.caverock.androidsvg.SVGImageView;
import com.caverock.androidsvg.SVGParseException;

import org.thoughtcrime.securesms.BaseActionBarActivity;
import org.thoughtcrime.securesms.R;
Expand Down Expand Up @@ -115,10 +118,25 @@ public void onItemClick(String proxyUrl) {

@Override
public void onItemShare(String proxyUrl) {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, proxyUrl);
startActivity(Intent.createChooser(intent, getString(R.string.chat_share_with_title)));
View view = View.inflate(this, R.layout.dialog_share_proxy, null);
SVGImageView qrImage = view.findViewById(R.id.qr_image);
try {
SVG svg = SVG.getFromString(DcHelper.getContext(this).createQrSvg(proxyUrl));
qrImage.setSVG(svg);
} catch (SVGParseException e) {
e.printStackTrace();
}

AlertDialog dialog = new AlertDialog.Builder(this)
.setView(view)
.setPositiveButton(android.R.string.ok, null)
.setNeutralButton(R.string.proxy_share_link, (dlg, btn) -> {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, proxyUrl);
startActivity(Intent.createChooser(intent, getString(R.string.chat_share_with_title)));
})
.show();
}

@Override
Expand Down
18 changes: 8 additions & 10 deletions src/main/java/org/thoughtcrime/securesms/qr/QrActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.core.view.MenuCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;
Expand All @@ -42,7 +42,7 @@
import java.io.FileNotFoundException;
import java.io.InputStream;

public class QrActivity extends BaseActionBarActivity {
public class QrActivity extends BaseActionBarActivity implements View.OnClickListener {

private final static String TAG = QrActivity.class.getSimpleName();
private final static int REQUEST_CODE_IMAGE = 46243;
Expand All @@ -64,7 +64,7 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.activity_qr);
qrShowFragment = new QrShowFragment();
qrShowFragment = new QrShowFragment(this);
tabLayout = ViewUtil.findById(this, R.id.tab_layout);
viewPager = ViewUtil.findById(this, R.id.pager);
ProfilePagerAdapter adapter = new ProfilePagerAdapter(this, getSupportFragmentManager());
Expand Down Expand Up @@ -115,7 +115,6 @@ public boolean onPrepareOptionsMenu(Menu menu) {
menu.findItem(R.id.new_classic_contact).setVisible(!DcHelper.getContext(this).isChatmail());
if(tabLayout.getSelectedTabPosition() == TAB_SCAN) {
menu.findItem(R.id.withdraw).setVisible(false);
menu.findItem(R.id.copy).setVisible(false);
}
return super.onPrepareOptionsMenu(menu);
}
Expand All @@ -131,12 +130,6 @@ public boolean onOptionsItemSelected(MenuItem item) {
case R.id.new_classic_contact:
this.startActivity(new Intent(this, NewContactActivity.class));
break;
case R.id.share:
qrShowFragment.shareQr();
break;
case R.id.copy:
qrShowFragment.copyQrData();
break;
case R.id.withdraw:
qrShowFragment.withdrawQr();
break;
Expand Down Expand Up @@ -206,6 +199,11 @@ public void onActivityResult(int reqCode, int resultCode, final Intent data) {
}
}

@Override
public void onClick(View v) {
viewPager.setCurrentItem(TAB_SCAN);
}

private class ProfilePagerAdapter extends FragmentStatePagerAdapter {

private final QrActivity activity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,6 @@ public boolean onOptionsItemSelected(MenuItem item) {
case android.R.id.home:
finish();
return true;
case R.id.share:
fragment.shareQr();
break;
case R.id.copy:
fragment.copyQrData();
break;
case R.id.withdraw:
fragment.withdrawQr();
break;
Expand Down
35 changes: 34 additions & 1 deletion src/main/java/org/thoughtcrime/securesms/qr/QrShowFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.NonNull;
Expand Down Expand Up @@ -52,6 +54,17 @@ public class QrShowFragment extends Fragment implements DcEventCenter.DcEventDel

private DcContext dcContext;

private View.OnClickListener scanClicklistener;

public QrShowFragment() {
this(null);
}

public QrShowFragment(View.OnClickListener scanClicklistener) {
super();
this.scanClicklistener = scanClicklistener;
}

@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
Expand Down Expand Up @@ -87,7 +100,14 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
e.printStackTrace();
}

view.findViewById(R.id.share_link_button).setOnClickListener((v) -> shareInviteURL());
view.findViewById(R.id.share_link_button).setOnClickListener((v) -> showInviteLinkDialog());
Button scanBtn = view.findViewById(R.id.scan_qr_button);
if (scanClicklistener != null) {
scanBtn.setVisibility(View.VISIBLE);
scanBtn.setOnClickListener(scanClicklistener);
} else {
scanBtn.setVisibility(View.GONE);
}

return view;
}
Expand Down Expand Up @@ -157,6 +177,19 @@ public void withdrawQr() {
builder.create().show();
}

public void showInviteLinkDialog() {
View view = View.inflate(getActivity(), R.layout.dialog_share_invite_link, null);
String inviteURL = Util.QrDataToInviteURL(dcContext.getSecurejoinQr(chatId));
((TextView)view.findViewById(R.id.invite_link)).setText(inviteURL);
new AlertDialog.Builder(getActivity())
.setView(view)
.setNegativeButton(R.string.cancel, null)
.setNeutralButton(R.string.menu_copy_to_clipboard, (d, b) -> copyQrData())
.setPositiveButton(R.string.menu_share, (d, b) -> shareInviteURL())
.create()
.show();
}

@Override
public void onResume() {
super.onResume();
Expand Down
8 changes: 8 additions & 0 deletions src/main/res/drawable/ic_link_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#FFFFFF" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
<group
android:translateX="29"
android:translateY="12"
android:rotation="135">
<path android:fillColor="@android:color/white" android:pathData="M3.9,12c0,-1.71 1.39,-3.1 3.1,-3.1h4L11,7L7,7c-2.76,0 -5,2.24 -5,5s2.24,5 5,5h4v-1.9L7,15.1c-1.71,0 -3.1,-1.39 -3.1,-3.1zM8,13h8v-2L8,11v2zM17,7h-4v1.9h4c1.71,0 3.1,1.39 3.1,3.1s-1.39,3.1 -3.1,3.1h-4L13,17h4c2.76,0 5,-2.24 5,-5s-2.24,-5 -5,-5z"/>
</group>
</vector>
5 changes: 5 additions & 0 deletions src/main/res/drawable/ic_qr_code_scanner_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#FFFFFF" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">

<path android:fillColor="@android:color/white" android:pathData="M9.5,6.5v3h-3v-3H9.5M11,5H5v6h6V5L11,5zM9.5,14.5v3h-3v-3H9.5M11,13H5v6h6V13L11,13zM17.5,6.5v3h-3v-3H17.5M19,5h-6v6h6V5L19,5zM13,13h1.5v1.5H13V13zM14.5,14.5H16V16h-1.5V14.5zM16,13h1.5v1.5H16V13zM13,16h1.5v1.5H13V16zM14.5,17.5H16V19h-1.5V17.5zM16,16h1.5v1.5H16V16zM17.5,14.5H19V16h-1.5V14.5zM17.5,17.5H19V19h-1.5V17.5zM22,7h-2V4h-3V2h5V7zM22,22v-5h-2v3h-3v2H22zM2,22h5v-2H4v-3H2V22zM2,2v5h2V4h3V2H2z"/>

</vector>
Loading

0 comments on commit 7a738ab

Please sign in to comment.