Merge branch 'main' into adb/issue-3963

This commit is contained in:
adb
2025-11-02 00:03:31 +01:00
committed by GitHub
30 changed files with 53 additions and 467 deletions
+13
View File
@@ -1,5 +1,18 @@
# Delta Chat Android Changelog
## Unreleased
* metadata protection: protect Date header
* metadata protection: protect Autocrypt header
* better multi-device: synchronize group creation across devices
* data saving: do not send Autocrypt header in read receipts
* improve onboarding speed
* don't show badge counter in app icon for the permanent background notification
* remove deprecated "companion app" code
* remove deprecated "Watch Sent Folder" preference
* fix sorting of old media in gallery
* update to core 2.23.0
## v2.22.0
2025-10
-11
View File
@@ -109,17 +109,6 @@ This may take some days.
c) tap "Publish release"
## Release on Amazon Appstore
on <https://developer.amazon.com/dashboard>:
12. a) click "App List", for "Delta Chat", select "Add upcoming version" on the left
b) at "Step 1 / Existing file(s)" hit "Replace", upload the APK from above
c) on the "Step 1" page, add "Release notes" from CHANGELOG.md, hit "Next"
d) on "Step 2" and "Step 3" pages, hit "Next"
e) on "Step 4" page: "Submit app"
## Release on Huawei AppGallery
on <https://developer.huawei.com/consumer/en/appgallery>:
+2 -7
View File
@@ -536,10 +536,10 @@ JNIEXPORT jint Java_com_b44t_messenger_DcContext_createChatByContactId(JNIEnv *e
}
JNIEXPORT jint Java_com_b44t_messenger_DcContext_createGroupChat(JNIEnv *env, jobject obj, jboolean verified, jstring name)
JNIEXPORT jint Java_com_b44t_messenger_DcContext_createGroupChat(JNIEnv *env, jobject obj, jstring name)
{
CHAR_REF(name);
jint ret = (jint)dc_create_group_chat(get_dc_context(env, obj), verified, namePtr);
jint ret = (jint)dc_create_group_chat(get_dc_context(env, obj), 0, namePtr);
CHAR_UNREF(name);
return ret;
}
@@ -1261,11 +1261,6 @@ JNIEXPORT jboolean Java_com_b44t_messenger_DcChat_canSend(JNIEnv *env, jobject o
}
JNIEXPORT jboolean Java_com_b44t_messenger_DcChat_isProtected(JNIEnv *env, jobject obj)
{
return dc_chat_is_protected(get_dc_chat(env, obj))!=0;
}
JNIEXPORT jboolean Java_com_b44t_messenger_DcChat_isSendingLocations(JNIEnv *env, jobject obj)
{
@@ -54,7 +54,7 @@ public class ForwardingTest {
// The thing is, DC_STATE_OUT_PENDING show a rotating circle animation, and Espresso doesn't work
// with animations, and the tests would hang and never finish.
dcContext.setConfig("bcc_self", "0");
activityRule.getScenario().onActivity(a -> createdGroupId = DcHelper.getContext(a).createGroupChat(false, "group"));
activityRule.getScenario().onActivity(a -> createdGroupId = DcHelper.getContext(a).createGroupChat( "group"));
}
@After
@@ -52,7 +52,7 @@ public class SharingTest {
@Before
public void createGroup() {
activityRule.getScenario().onActivity(a -> createdGroupId = DcHelper.getContext(a).createGroupChat(false, "group"));
activityRule.getScenario().onActivity(a -> createdGroupId = DcHelper.getContext(a).createGroupChat( "group"));
}
@Before
-23
View File
@@ -239,18 +239,6 @@
android:windowSoftInputMode="stateUnchanged"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- this scheme is used as the redirect_url for getOauth2Url()
and should be whitelisted by the supported oauth2 services -->
<data android:scheme="chat.delta" android:path="/${applicationId}/auth" tools:ignore="AppLinkUrlError"/>
<data android:scheme="chat.delta" android:path="/auth" tools:ignore="AppLinkUrlError"/>
</intent-filter>
</activity>
<activity android:name=".proxy.ProxySettingsActivity"
@@ -417,17 +405,6 @@
android:name=".service.FetchForegroundService"
android:foregroundServiceType="dataSync" />
<service
android:name=".service.IPCAddAccountsService"
android:foregroundServiceType="dataSync"
android:enabled="true"
android:exported="true"
>
<intent-filter>
<action android:name="chat.delta.addaccount" />
</intent-filter>
</service>
<receiver android:name=".notifications.MarkReadReceiver"
android:enabled="true"
android:exported="false">
@@ -44,7 +44,6 @@ public class DcChat {
public native boolean isSelfTalk ();
public native boolean isDeviceTalk ();
public native boolean canSend ();
public native boolean isProtected ();
public native boolean isSendingLocations();
public native boolean isMuted ();
public native boolean isContactRequest ();
@@ -71,9 +71,6 @@ public class DcContext {
public final static int DC_QR_REVIVE_VERIFYGROUP = 512;
public final static int DC_QR_LOGIN = 520;
public final static int DC_LP_AUTH_OAUTH2 = 0x2;
public final static int DC_LP_AUTH_NORMAL = 0x4;
public final static int DC_SOCKET_AUTO = 0;
public final static int DC_SOCKET_SSL = 1;
public final static int DC_SOCKET_STARTTLS = 2;
@@ -145,7 +142,6 @@ public class DcContext {
public native String getInfo ();
public native int getConnectivity ();
public native String getConnectivityHtml ();
public native String getOauth2Url (String addr, String redirectUrl);
public native String initiateKeyTransfer ();
public native void imex (int what, String dir);
public native String imexHasBackup (String dir);
@@ -169,7 +165,7 @@ public class DcContext {
public native void setChatVisibility (int chat_id, int visibility);
public native int getChatIdByContactId (int contact_id);
public native int createChatByContactId(int contact_id);
public native int createGroupChat (boolean verified, String name);
public native int createGroupChat (String name);
public native int createBroadcastList ();
public native boolean isContactInChat (int chat_id, int contact_id);
public native int addContactToChat (int chat_id, int contact_id);
@@ -246,15 +242,6 @@ public class DcContext {
setConfigInt("is_muted", muted? 1 : 0);
}
public boolean isGmailOauth2Addr(String addr) {
final String oauth2url = getOauth2Url(addr, "chat.delta:/foo");
return isGmailOauth2Url(oauth2url);
}
public boolean isGmailOauth2Url(String oauth2url) {
return oauth2url.startsWith("https://accounts.google.com/");
}
public void restartIo() {
stopIo();
startIo();
@@ -68,8 +68,8 @@ public class AllMediaActivity extends PassphraseRequiredActionBarActivity
protected void onCreate(Bundle bundle, boolean ready) {
tabs.add(new TabData(R.string.webxdc_apps, DcMsg.DC_MSG_WEBXDC, 0, 0));
tabs.add(new TabData(R.string.tab_gallery, DcMsg.DC_MSG_IMAGE, DcMsg.DC_MSG_GIF, DcMsg.DC_MSG_VIDEO));
tabs.add(new TabData(R.string.files, DcMsg.DC_MSG_FILE, 0, 0));
tabs.add(new TabData(R.string.audio, DcMsg.DC_MSG_AUDIO, DcMsg.DC_MSG_VOICE, 0));
tabs.add(new TabData(R.string.files, DcMsg.DC_MSG_FILE, 0, 0));
setContentView(R.layout.all_media_activity);
@@ -12,6 +12,7 @@ import android.util.Log;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.core.app.NotificationManagerCompat;
import androidx.multidex.MultiDexApplication;
import androidx.work.Constraints;
import androidx.work.ExistingPeriodicWorkPolicy;
@@ -89,6 +90,12 @@ public class ApplicationContext extends MultiDexApplication {
dcAccounts = new DcAccounts(new File(getFilesDir(), "accounts").getAbsolutePath());
rpc = new Rpc(new FFITransport(dcAccounts.getJsonrpcInstance()));
AccountManager.getInstance().migrateToDcAccounts(this);
// October-2025 migration: delete deprecated "permanent channel" id
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
notificationManager.deleteNotificationChannel("dc_foreground_notification_ch");
// end October-2025 migration
int[] allAccounts = dcAccounts.getAll();
for (int accountId : allAccounts) {
DcContext ac = dcAccounts.getAccount(accountId);
@@ -79,7 +79,6 @@ public class ContactSelectionListFragment extends Fragment
private static final String TAG = ContactSelectionListFragment.class.getSimpleName();
public static final String MULTI_SELECT = "multi_select";
public static final String SELECT_VERIFIED_EXTRA = "select_verified";
public static final String SELECT_UNENCRYPTED_EXTRA = "select_unencrypted_extra";
public static final String ALLOW_CREATION = "allow_creation";
public static final String PRESELECTED_CONTACTS = "preselected_contacts";
@@ -240,10 +239,6 @@ public class ContactSelectionListFragment extends Fragment
return getActivity().getIntent().getBooleanExtra(MULTI_SELECT, false);
}
private boolean isSelectVerfied() {
return getActivity().getIntent().getBooleanExtra(SELECT_VERIFIED_EXTRA, false);
}
private boolean isUnencrypted() {
return getActivity().getIntent().getBooleanExtra(SELECT_UNENCRYPTED_EXTRA, false);
}
@@ -348,17 +343,6 @@ public class ContactSelectionListFragment extends Fragment
return;
}
if (isSelectVerfied() && !contact.getDcContact().isVerified()) {
new AlertDialog.Builder(getActivity())
.setMessage(R.string.verified_contact_required_explain)
.setNeutralButton(R.string.learn_more, (d, w) -> DcHelper.openHelp(getActivity(), "#howtoe2ee"))
.setNegativeButton(R.string.qrscan_title, (d, w) -> getActivity().startActivity(new Intent(getActivity(), QrActivity.class)))
.setPositiveButton(R.string.ok, null)
.setCancelable(true)
.show();
return;
}
selectedContacts.add(contactId);
contact.setChecked(true);
if (onContactSelectedListener != null) {
@@ -133,19 +133,6 @@ public class ConversationListActivity extends PassphraseRequiredActionBarActivit
Prefs.setStringPreference(this, Prefs.LAST_DEVICE_MSG_LABEL, deviceMsgLabel);
}
// remove gmail oauth2
final int serverFlags = dcContext.getConfigInt(CONFIG_SERVER_FLAGS);
if ((serverFlags & DcContext.DC_LP_AUTH_OAUTH2)!=0) {
Util.runOnAnyBackgroundThread(() -> {
if (dcContext.isGmailOauth2Addr(dcContext.getConfig(CONFIG_ADDRESS))) {
final DcMsg msg = new DcMsg(dcContext, DcMsg.DC_MSG_TEXT);
msg.setText("⚠️ GMail Users: If you have problems using GMail, go to \"Settings / Advanced / Password and Account\".\n\nThere, login again using an \"App Password\".");
dcContext.addDeviceMsg("info_about_gmail_oauth2_removal8", msg);
}
});
}
// /remove gmail oauth2
} catch(Exception e) {
e.printStackTrace();
}
@@ -60,7 +60,6 @@ public class GroupCreateActivity extends PassphraseRequiredActionBarActivity
private DcContext dcContext;
private boolean verified;
private boolean unencrypted;
private boolean broadcast;
private EditText groupName;
@@ -77,7 +76,6 @@ public class GroupCreateActivity extends PassphraseRequiredActionBarActivity
protected void onCreate(Bundle state, boolean ready) {
dcContext = DcHelper.getContext(this);
setContentView(R.layout.group_create_activity);
verified = false;
broadcast = getIntent().getBooleanExtra(CREATE_BROADCAST, false);
unencrypted = getIntent().getBooleanExtra(UNENCRYPTED, false);
Objects.requireNonNull(getSupportActionBar()).setDisplayHomeAsUpEnabled(true);
@@ -93,7 +91,6 @@ public class GroupCreateActivity extends PassphraseRequiredActionBarActivity
if(groupChatId !=0) {
isEdit = true;
DcChat dcChat = dcContext.getChat(groupChatId);
verified = dcChat.isProtected();
broadcast = dcChat.isOutBroadcast();
unencrypted = !dcChat.isEncrypted();
}
@@ -234,7 +231,6 @@ public class GroupCreateActivity extends PassphraseRequiredActionBarActivity
if (groupChatId != 0) {
updateGroup(groupName);
} else {
verified = !unencrypted && !broadcast && allMembersVerified();
createGroup(groupName);
}
@@ -244,21 +240,10 @@ public class GroupCreateActivity extends PassphraseRequiredActionBarActivity
return false;
}
private boolean allMembersVerified() {
for (int id : getAdapter().getContacts()) {
DcContact contact = dcContext.getContact(id);
if (contact != null && !contact.isVerified()) {
return false;
}
}
return true;
}
@Override
public void onItemClick(int contactId) {
if (contactId == DcContact.DC_CONTACT_ID_ADD_MEMBER) {
Intent intent = new Intent(this, ContactMultiSelectionActivity.class);
intent.putExtra(ContactSelectionListFragment.SELECT_VERIFIED_EXTRA, verified);
intent.putExtra(ContactSelectionListFragment.SELECT_UNENCRYPTED_EXTRA, unencrypted);
ArrayList<Integer> preselectedContacts = new ArrayList<>(getAdapter().getContacts());
intent.putExtra(ContactSelectionListFragment.PRESELECTED_CONTACTS, preselectedContacts);
@@ -287,7 +272,7 @@ public class GroupCreateActivity extends PassphraseRequiredActionBarActivity
return;
}
} else {
groupChatId = dcContext.createGroupChat(verified, groupName);
groupChatId = dcContext.createGroupChat(groupName);
}
for (int contactId : getAdapter().getContacts()) {
@@ -68,7 +68,7 @@ public class InstantOnboardingActivity extends BaseActionBarActivity implements
private static final String TAG = InstantOnboardingActivity.class.getSimpleName();
private static final String DCACCOUNT = "dcaccount";
private static final String DCLOGIN = "dclogin";
private static final String INSTANCES_URL = "https://delta.chat/chatmail";
private static final String INSTANCES_URL = "https://chatmail.at/relays";
private static final String DEFAULT_CHATMAIL_HOST = "nine.testrun.org";
public static final String QR_ACCOUNT_EXTRA = "qr_account_extra";
@@ -201,7 +201,6 @@ public class ProfileFragment extends Fragment
public void onAddMember() {
DcChat dcChat = dcContext.getChat(chatId);
Intent intent = new Intent(getContext(), ContactMultiSelectionActivity.class);
intent.putExtra(ContactSelectionListFragment.SELECT_VERIFIED_EXTRA, dcChat.isProtected());
ArrayList<Integer> preselectedContacts = new ArrayList<>();
for (int memberId : dcContext.getChatContacts(chatId)) {
preselectedContacts.add(memberId);
@@ -12,15 +12,11 @@ import static org.thoughtcrime.securesms.connect.DcHelper.CONFIG_SEND_PORT;
import static org.thoughtcrime.securesms.connect.DcHelper.CONFIG_SEND_SECURITY;
import static org.thoughtcrime.securesms.connect.DcHelper.CONFIG_SEND_SERVER;
import static org.thoughtcrime.securesms.connect.DcHelper.CONFIG_SEND_USER;
import static org.thoughtcrime.securesms.connect.DcHelper.CONFIG_SERVER_FLAGS;
import static org.thoughtcrime.securesms.connect.DcHelper.getContext;
import static org.thoughtcrime.securesms.service.IPCAddAccountsService.ACCOUNT_DATA;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Resources;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextUtils;
@@ -39,7 +35,6 @@ import androidx.annotation.IdRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.SwitchCompat;
import androidx.constraintlayout.widget.Group;
@@ -58,16 +53,11 @@ import org.thoughtcrime.securesms.util.Util;
import org.thoughtcrime.securesms.util.ViewUtil;
import org.thoughtcrime.securesms.util.views.ProgressDialog;
import java.lang.ref.WeakReference;
import java.util.concurrent.ExecutionException;
import chat.delta.rpc.Rpc;
import chat.delta.rpc.RpcException;
import chat.delta.rpc.types.EnteredCertificateChecks;
import chat.delta.rpc.types.EnteredLoginParam;
import chat.delta.rpc.types.Socket;
import chat.delta.util.ListenableFuture;
import chat.delta.util.SettableFuture;
public class RegistrationActivity extends BaseActionBarActivity implements DcEventCenter.DcEventDelegate {
@@ -94,7 +84,6 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve
Spinner imapSecurity;
Spinner smtpSecurity;
Spinner authMethod;
Spinner certCheck;
private SwitchCompat proxySwitch;
@@ -125,7 +114,6 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve
imapSecurity = findViewById(R.id.imap_security);
smtpSecurity = findViewById(R.id.smtp_security);
authMethod = findViewById(R.id.auth_method);
certCheck = findViewById(R.id.cert_check);
proxySwitch = findViewById(R.id.proxy_settings);
@@ -216,42 +204,12 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve
smtpSecurity.setSelection(ViewUtil.checkBounds(intVal, smtpSecurity));
expandAdvanced = expandAdvanced || intVal != 0;
int serverFlags = DcHelper.getInt(this, CONFIG_SERVER_FLAGS);
int sel = 0;
if((serverFlags&DcContext.DC_LP_AUTH_OAUTH2)!=0) {
sel = 1;
// remove gmail oauth2
if (DcHelper.getContext(this).isGmailOauth2Addr(email)) { // this is a blocking call, not perfect, but as rarely used and temporary, good enough
sel = 0;
updateProviderInfo(); // we refer to the hints in the device message, show them immediately
}
// /remove gmail oauth2
}
authMethod.setSelection(ViewUtil.checkBounds(sel, authMethod));
expandAdvanced = expandAdvanced || sel != 0;
int imapCertificateChecks = DcHelper.getInt(this, "imap_certificate_checks");
if (imapCertificateChecks == 3) {
imapCertificateChecks = 2; // 3 is a deprecated alias for 2
}
certCheck.setSelection(ViewUtil.checkBounds(imapCertificateChecks, certCheck));
expandAdvanced = expandAdvanced || imapCertificateChecks != 0;
} else if (getIntent() != null && getIntent().getBundleExtra(ACCOUNT_DATA) != null) {
// Companion app might have sent account data
Bundle b = getIntent().getBundleExtra(ACCOUNT_DATA);
String emailAddress = b.getString(CONFIG_ADDRESS);
String password = b.getString(CONFIG_MAIL_PASSWORD);
if (!TextUtils.isEmpty(emailAddress) && !TextUtils.isEmpty(password)) {
emailInput.setText(emailAddress);
passwordInput.setText(password);
onLogin();
} else {
String errorText = "Companion app auto-configuration failed.";
errorText += TextUtils.isEmpty(emailAddress) ? " Missing emailAddress." : "";
errorText += TextUtils.isEmpty(password) ? " Missing password." : "";
Toast.makeText(this, errorText, Toast.LENGTH_LONG).show();
}
}
if (expandAdvanced) { onAdvancedSettings(); }
@@ -287,7 +245,8 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve
int id = item.getItemId();
if (id == R.id.do_register) {
do_register();
updateProviderInfo();
onLogin();
return true;
} else if (id == android.R.id.home) {
// handle close button click here
@@ -297,26 +256,6 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve
return super.onOptionsItemSelected(item);
}
private void do_register() {
// "log in" button clicked - even if oauth2DeclinedByUser is true,
// we will ask for oauth2 to allow reverting the decision.
checkOauth2start().addListener(new ListenableFuture.Listener<Boolean>() {
@Override
public void onSuccess(Boolean oauth2started) {
if(!oauth2started) {
updateProviderInfo();
onLogin();
}
}
@Override
public void onFailure(ExecutionException e) {
updateProviderInfo();
onLogin();
}
});
}
@Override
public void onDestroy() {
super.onDestroy();
@@ -335,23 +274,7 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve
switch (type) {
case EMAIL:
verifyEmail(inputEditText);
if (!oauth2DeclinedByUser) {
checkOauth2start().addListener(new ListenableFuture.Listener<Boolean>() {
@Override
public void onSuccess(Boolean oauth2started) {
if (!oauth2started) {
updateProviderInfo();
}
}
@Override
public void onFailure(ExecutionException e) {
updateProviderInfo();
}
});
} else {
updateProviderInfo();
}
updateProviderInfo();
break;
case SERVER:
verifyServer(inputEditText);
@@ -363,86 +286,6 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve
}
}
private long oauth2Requested = 0;
// this flag is set, if the user has declined oauth2 at some point;
// if so, we won't bother em on focus changes again,
// however, to allow reverting the decision, we will always ask on clicking the login button.
private boolean oauth2DeclinedByUser = false;
// this function checks if oauth2 is available for a given email address
// and and asks the user if one wants to start oauth2.
// the function returns the future "true" if oauth2 was started and "false" otherwise.
private ListenableFuture<Boolean> checkOauth2start() {
SettableFuture<Boolean> oauth2started = new SettableFuture<>();
String email = emailInput.getText().toString();
if (!TextUtils.isEmpty(email) ) {
new PrecheckOauth2AsyncTask(this, email, oauth2started).execute();
}
else {
oauth2started.set(false);
}
return oauth2started;
}
private static class PrecheckOauth2AsyncTask extends AsyncTask<Void, Void, Void> {
private final WeakReference<RegistrationActivity> activityWeakReference;
private final String email;
private final SettableFuture<Boolean> oauth2started;
private final DcContext dcContext;
private @NonNull String oauth2url = "";
public PrecheckOauth2AsyncTask(RegistrationActivity activity, String email, SettableFuture<Boolean> oauth2started) {
super();
this.activityWeakReference = new WeakReference<>(activity);
this.email = email;
this.oauth2started = oauth2started;
this.dcContext = DcHelper.getContext(activity);
}
@Override
protected Void doInBackground(Void... voids) {
// the redirect-uri is also used as intent-filter in the manifest
// and should be whitelisted by the supported oauth2 services
String redirectUrl = "chat.delta:/"+BuildConfig.APPLICATION_ID+"/auth";
oauth2url = dcContext.getOauth2Url(email, redirectUrl);
// remove gmail oauth2
if (dcContext.isGmailOauth2Url(oauth2url)) {
oauth2url = null;
}
// /remove gmail oauth2
return null;
}
@Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
RegistrationActivity activity = activityWeakReference.get();
if (activity!=null && !TextUtils.isEmpty(oauth2url)) {
new AlertDialog.Builder(activity)
.setTitle(R.string.login_info_oauth2_title)
.setMessage(R.string.login_info_oauth2_text)
.setNegativeButton(R.string.cancel, (dialog, which)->{
activity.oauth2DeclinedByUser = true;
oauth2started.set(false);
})
.setPositiveButton(R.string.perm_continue, (dialog, which)-> {
// pass control to browser, we'll be back in business at (**)
activity.oauth2Requested = System.currentTimeMillis();
IntentUtils.showInBrowser(activity, oauth2url);
oauth2started.set(true);
})
.setCancelable(false)
.show();
} else {
oauth2started.set(false);
}
}
}
private void updateProviderInfo() {
Util.runOnBackground(() -> {
provider = getContext(this).getProviderFromEmailWithDns(emailInput.getText().toString());
@@ -495,27 +338,6 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve
}
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
if(Intent.ACTION_VIEW.equals(intent.getAction())) {
Uri uri = intent.getData();
String path = uri.getPath();
if(!(path.startsWith("/"+BuildConfig.APPLICATION_ID)||path.startsWith("/auth"))
|| System.currentTimeMillis()-oauth2Requested > 3*60*60*1000) {
return; // timeout after some hours or a request belonging to a bad path.
}
// back in business after we passed control to the browser in (**)
String code = uri.getQueryParameter("code");
if(!TextUtils.isEmpty(code)) {
passwordInput.setText(code);
authMethod.setSelection(1/*OAuth2*/);
onLogin();
}
}
}
private void verifyEmail(TextInputEditText view) {
String error = getString(R.string.login_error_mail);
String email = view.getText().toString();
@@ -634,7 +456,6 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve
param.smtpUser = getParam(R.id.smtp_login_text, false);
param.smtpPassword = getParam(R.id.smtp_password_text, false);
param.certificateChecks = certificateChecksFromInt(certCheck.getSelectedItemPosition());
param.oauth2 = authMethod.getSelectedItemPosition() == 1;
new Thread(() -> {
Rpc rpc = DcHelper.getRpc(this);
@@ -51,7 +51,6 @@ public class WelcomeActivity extends BaseActionBarActivity implements DcEventCen
public static final int PICK_BACKUP = 20574;
private final static String TAG = WelcomeActivity.class.getSimpleName();
public static final String TMP_BACKUP_FILE = "tmp-backup-file";
public static final String DC_REQUEST_ACCOUNT_DATA = "chat.delta.DC_REQUEST_ACCOUNT_DATA";
private ProgressDialog progressDialog = null;
private boolean imexUserAborted;
@@ -87,16 +86,6 @@ public class WelcomeActivity extends BaseActionBarActivity implements DcEventCen
registerForEvents();
initializeActionBar();
if (!DcHelper.hasAnyConfiguredContext(this)) {
Intent intent = new Intent();
// Since android API 26 only explicit broadcasts are allowed for IPC with a few exceptions.
// As a result we have to send for each companion app we want to support an intent with a
// specified package
intent.setPackage("chat.delta.androidyggmail");
intent.setAction(DC_REQUEST_ACCOUNT_DATA);
sendBroadcast(intent);
}
DcHelper.maybeShowMigrationError(this);
}
@@ -64,7 +64,6 @@ public class DcHelper {
public static final String CONFIG_DISPLAY_NAME = "displayname";
public static final String CONFIG_SELF_STATUS = "selfstatus";
public static final String CONFIG_SELF_AVATAR = "selfavatar";
public static final String CONFIG_SENTBOX_WATCH = "sentbox_watch";
public static final String CONFIG_MVBOX_MOVE = "mvbox_move";
public static final String CONFIG_ONLY_FETCH_MVBOX = "only_fetch_mvbox";
public static final String CONFIG_BCC_SELF = "bcc_self";
@@ -95,27 +94,11 @@ public class DcHelper {
return ApplicationContext.getInstance(context).notificationCenter;
}
public static boolean hasAnyConfiguredContext(Context context) {
DcAccounts accounts = getAccounts(context);
int[] accountIds = accounts.getAll();
for (int accountId : accountIds) {
if (accounts.getAccount(accountId).isConfigured() == 1) {
return true;
}
}
return false;
}
public static boolean isConfigured(Context context) {
DcContext dcContext = getContext(context);
return dcContext.isConfigured() == 1;
}
public static String getSelfAddr(Context context) {
DcContext dcContext = getContext(context);
return dcContext.getConfig(CONFIG_CONFIGURED_ADDRESS);
}
public static int getInt(Context context, String key) {
DcContext dcContext = getContext(context);
return dcContext.getConfigInt(key);
@@ -160,7 +143,6 @@ public class DcHelper {
dcContext.setStockTranslation(69, context.getString(R.string.saved_messages));
dcContext.setStockTranslation(70, context.getString(R.string.device_talk_explain));
dcContext.setStockTranslation(71, context.getString(R.string.device_talk_welcome_message2));
dcContext.setStockTranslation(72, context.getString(R.string.systemmsg_unknown_sender_for_chat));
dcContext.setStockTranslation(73, context.getString(R.string.systemmsg_subject_for_new_contact));
dcContext.setStockTranslation(74, context.getString(R.string.systemmsg_failed_sending_to));
dcContext.setStockTranslation(84, context.getString(R.string.configuration_failed_with_error));
@@ -414,7 +396,7 @@ public class DcHelper {
return new ThreadRecord(body, recipient, date,
unreadCount, chatId,
chat.getVisibility(), chat.isProtected(), chat.isSendingLocations(), chat.isMuted(), chat.isContactRequest(), summary);
chat.getVisibility(), chat.isSendingLocations(), chat.isMuted(), chat.isContactRequest(), summary);
}
public static boolean isNetworkConnected(Context context) {
@@ -151,11 +151,11 @@ public class DirectShareUtil {
}
private static @NonNull Bitmap getShortcutInfoBitmap(@NonNull Context context, @NonNull Recipient recipient) throws ExecutionException, InterruptedException {
return DrawableUtil.wrapBitmapForShortcutInfo(request(GlideApp.with(context).asBitmap(), context, recipient).circleCrop().submit().get());
return DrawableUtil.wrapBitmapForShortcutInfo(request(GlideApp.with(context).asBitmap(), context, recipient).submit().get());
}
private static Bitmap getFallbackDrawable(Context context, @NonNull Recipient recipient) {
return BitmapUtil.createFromDrawable(recipient.getFallbackAvatarDrawable(context),
return BitmapUtil.createFromDrawable(recipient.getFallbackAvatarDrawable(context, false),
context.getResources().getDimensionPixelSize(android.R.dimen.notification_large_icon_width),
context.getResources().getDimensionPixelSize(android.R.dimen.notification_large_icon_height));
}
@@ -121,6 +121,7 @@ public class KeepAliveService extends Service {
NotificationChannel channel = new NotificationChannel(NotificationCenter.CH_PERMANENT,
"Receive messages in background.", NotificationManager.IMPORTANCE_MIN); // IMPORTANCE_DEFAULT will play a sound
channel.setDescription("Ensure reliable message receiving.");
channel.setShowBadge(false);
NotificationManager notificationManager = context.getSystemService(NotificationManager.class);
notificationManager.createNotificationChannel(channel);
}
@@ -238,7 +238,7 @@ public class BucketedThreadMediaLoader extends AsyncTaskLoader<BucketedThreadMed
private static class MonthBuckets {
private final Map<Date, List<DcMsg>> months = new HashMap<>();
private final Map<Date, LinkedList<DcMsg>> months = new HashMap<>();
void add(DcMsg record) {
Calendar calendar = Calendar.getInstance();
@@ -249,9 +249,9 @@ public class BucketedThreadMediaLoader extends AsyncTaskLoader<BucketedThreadMed
Date date = new Date(year, month, 1);
if (months.containsKey(date)) {
months.get(date).add(record);
months.get(date).addFirst(record);
} else {
List<DcMsg> list = new LinkedList<>();
LinkedList<DcMsg> list = new LinkedList<>();
list.add(record);
months.put(date, list);
}
@@ -43,7 +43,6 @@ public class ThreadRecord {
private final int unreadCount;
private final int visibility;
private final boolean isProtected;
private final boolean isSendingLocations;
private final boolean isMuted;
private final boolean isContactRequest;
@@ -53,7 +52,6 @@ public class ThreadRecord {
@NonNull Recipient recipient, long dateReceived, int unreadCount,
long threadId,
int visibility,
boolean isProtected,
boolean isSendingLocations,
boolean isMuted,
boolean isContactRequest,
@@ -65,7 +63,6 @@ public class ThreadRecord {
this.body = body;
this.unreadCount = unreadCount;
this.visibility = visibility;
this.isProtected = isProtected;
this.isSendingLocations = isSendingLocations;
this.isMuted = isMuted;
this.isContactRequest = isContactRequest;
@@ -116,10 +113,6 @@ public class ThreadRecord {
return visibility;
}
public boolean isProtected() {
return isProtected;
}
public boolean isSendingLocations() {
return isSendingLocations;
}
@@ -241,7 +241,7 @@ public class NotificationCenter {
// channelIds: CH_MSG_* are used here, the other ones from outside (defined here to have some overview)
public static final String CH_MSG_PREFIX = "ch_msg";
public static final String CH_MSG_VERSION = "5";
public static final String CH_PERMANENT = "dc_foreground_notification_ch";
public static final String CH_PERMANENT = "dc_fg_notification_ch";
public static final String CH_GENERIC = "ch_generic";
public static final String CH_CALLS_PREFIX = "call_chan";
@@ -5,7 +5,6 @@ import static android.text.InputType.TYPE_TEXT_VARIATION_URI;
import static org.thoughtcrime.securesms.connect.DcHelper.CONFIG_BCC_SELF;
import static org.thoughtcrime.securesms.connect.DcHelper.CONFIG_MVBOX_MOVE;
import static org.thoughtcrime.securesms.connect.DcHelper.CONFIG_ONLY_FETCH_MVBOX;
import static org.thoughtcrime.securesms.connect.DcHelper.CONFIG_SENTBOX_WATCH;
import static org.thoughtcrime.securesms.connect.DcHelper.CONFIG_SHOW_EMAILS;
import static org.thoughtcrime.securesms.connect.DcHelper.CONFIG_WEBXDC_REALTIME_ENABLED;
import static org.thoughtcrime.securesms.connect.DcHelper.getRpc;
@@ -58,7 +57,6 @@ public class AdvancedPreferenceFragment extends ListSummaryPreferenceFragment
private static final String TAG = AdvancedPreferenceFragment.class.getSimpleName();
private ListPreference showEmails;
CheckBoxPreference sentboxWatchCheckbox;
CheckBoxPreference bccSelfCheckbox;
CheckBoxPreference mvboxMoveCheckbox;
CheckBoxPreference onlyFetchMvboxCheckbox;
@@ -83,15 +81,6 @@ public class AdvancedPreferenceFragment extends ListSummaryPreferenceFragment
sendAsm.setOnPreferenceClickListener(new SendAsmListener());
}
sentboxWatchCheckbox = (CheckBoxPreference) this.findPreference("pref_sentbox_watch");
if (sentboxWatchCheckbox != null) {
sentboxWatchCheckbox.setOnPreferenceChangeListener((preference, newValue) -> {
boolean enabled = (Boolean) newValue;
dcContext.setConfigInt(CONFIG_SENTBOX_WATCH, enabled? 1 : 0);
return true;
});
}
bccSelfCheckbox = (CheckBoxPreference) this.findPreference("pref_bcc_self");
if (bccSelfCheckbox != null) {
bccSelfCheckbox.setOnPreferenceChangeListener((preference, newValue) -> {
@@ -261,7 +250,6 @@ public class AdvancedPreferenceFragment extends ListSummaryPreferenceFragment
if (dcContext.isChatmail()) {
showEmails.setVisible(false);
showSystemContacts.setVisible(false);
sentboxWatchCheckbox.setVisible(false);
bccSelfCheckbox.setVisible(false);
mvboxMoveCheckbox.setVisible(false);
onlyFetchMvboxCheckbox.setVisible(false);
@@ -282,7 +270,6 @@ public class AdvancedPreferenceFragment extends ListSummaryPreferenceFragment
showEmails.setValue(value);
updateListSummary(showEmails, value);
sentboxWatchCheckbox.setChecked(0!=dcContext.getConfigInt(CONFIG_SENTBOX_WATCH));
bccSelfCheckbox.setChecked(0!=dcContext.getConfigInt(CONFIG_BCC_SELF));
mvboxMoveCheckbox.setChecked(0!=dcContext.getConfigInt(CONFIG_MVBOX_MOVE));
onlyFetchMvboxCheckbox.setChecked(0!=dcContext.getConfigInt(CONFIG_ONLY_FETCH_MVBOX));
@@ -277,7 +277,7 @@ public class ChatsPreferenceFragment extends ListSummaryPreferenceFragment {
.setTitle(R.string.pref_backup)
.setMessage(R.string.pref_backup_export_explain)
.setNeutralButton(android.R.string.cancel, null)
.setPositiveButton(requireActivity().getString(R.string.pref_backup_export_x, addr), (dialogInterface, i) -> startImexOne(DcContext.DC_IMEX_EXPORT_BACKUP));
.setPositiveButton(requireActivity().getString(R.string.pref_backup_export_this, addr), (dialogInterface, i) -> startImexOne(DcContext.DC_IMEX_EXPORT_BACKUP));
int[] allAccounts = DcHelper.getAccounts(requireActivity()).getAll();
if (allAccounts.length > 1) {
String exportAllString = requireActivity().getString(R.string.pref_backup_export_all, allAccounts.length);
@@ -1,93 +0,0 @@
package org.thoughtcrime.securesms.service;
import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TASK;
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
import static org.thoughtcrime.securesms.connect.DcHelper.CONFIG_ADDRESS;
import static org.thoughtcrime.securesms.connect.DcHelper.CONFIG_CONFIGURED_ADDRESS;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.os.Messenger;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.b44t.messenger.DcAccounts;
import com.b44t.messenger.DcContext;
import org.thoughtcrime.securesms.ConversationListActivity;
import org.thoughtcrime.securesms.RegistrationActivity;
import org.thoughtcrime.securesms.connect.AccountManager;
import org.thoughtcrime.securesms.connect.DcHelper;
import java.lang.ref.WeakReference;
/**
* This (interprocess communication) service is invoked by companion apps aiming to add a new account to Delta Chat
*/
public class IPCAddAccountsService extends Service {
public final static int ADD_ACCOUNT = 1;
public final static String ACCOUNT_DATA = "ACCOUNT_DATA";
private static final String TAG = IPCAddAccountsService.class.getSimpleName();
private static class IncomingHandler extends Handler {
final WeakReference<Context> contextRef;
public IncomingHandler(Context context) {
contextRef = new WeakReference<>(context);
}
@Override
public void handleMessage(@NonNull Message msg) {
Bundle data = msg.getData();
Context context = contextRef.get();
if (data != null && context != null && msg.what == ADD_ACCOUNT) {
String newAddress = data.getString(CONFIG_ADDRESS);
Log.d(TAG, "ADD ACCOUNT called for account: " + newAddress);
// check if account already exists, if so, switch to that account
DcAccounts accounts = DcHelper.getAccounts(context);
int[] accountIds = accounts.getAll();
for (int accountId : accountIds) {
DcContext dcContext = accounts.getAccount(accountId);
String accountAddress = dcContext.getConfig(CONFIG_CONFIGURED_ADDRESS);
if (accountAddress.equals(newAddress)) {
Log.d(TAG, newAddress + " already exists. Switching account.");
AccountManager.getInstance().switchAccount(context, accountId);
Intent switchAccountIntent = new Intent(context, ConversationListActivity.class);
switchAccountIntent.addFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TASK);
context.startActivity(switchAccountIntent);
return;
}
}
AccountManager.getInstance().beginAccountCreation(context);
Intent registrationIntent = new Intent(context, RegistrationActivity.class);
registrationIntent.putExtra(ACCOUNT_DATA, data);
registrationIntent.addFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TASK);
context.startActivity(registrationIntent);
}
}
}
private final Messenger messenger = new Messenger(new IncomingHandler(this));
@Nullable
@Override
public IBinder onBind(Intent intent) {
return messenger.getBinder();
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
return START_NOT_STICKY;
}
}
+2 -22
View File
@@ -131,7 +131,7 @@
android:visibility="gone"
tools:visibility="visible"
app:constraint_referenced_ids="inbox, imap_login, imap_server, imap_port, imap_security_label, imap_security, outbox_view_spacer_top,
outbox, smtp_login, smtp_password, smtp_server, smtp_port, smtp_security_label, smtp_security, auth_method_label, auth_method, cert_check_label, cert_check, view_log_button, proxy_settings" />
outbox, smtp_login, smtp_password, smtp_server, smtp_port, smtp_security_label, smtp_security, cert_check_label, cert_check, view_log_button, proxy_settings" />
<ImageView
android:id="@+id/advanced_icon"
@@ -357,26 +357,6 @@
app:layout_constraintStart_toStartOf="@id/guideline_root_start"
app:layout_constraintTop_toBottomOf="@id/smtp_security_label" />
<TextView
android:id="@+id/auth_method_label"
style="@style/TextAppearance.AppCompat.Caption"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingTop="16dp"
android:text="@string/login_auth_method"
app:layout_constraintEnd_toEndOf="@id/guideline_root_end"
app:layout_constraintStart_toStartOf="@id/guideline_root_start"
app:layout_constraintTop_toBottomOf="@id/smtp_security" />
<Spinner
android:id="@+id/auth_method"
android:layout_width="0dp"
android:layout_height="48dp"
android:entries="@array/auth_methods"
app:layout_constraintEnd_toEndOf="@id/guideline_root_end"
app:layout_constraintStart_toStartOf="@id/guideline_root_start"
app:layout_constraintTop_toBottomOf="@id/auth_method_label" />
<TextView
android:id="@+id/cert_check_label"
style="@style/TextAppearance.AppCompat.Caption"
@@ -385,7 +365,7 @@
android:text="@string/login_certificate_checks"
app:layout_constraintEnd_toEndOf="@id/guideline_root_end"
app:layout_constraintStart_toStartOf="@id/guideline_root_start"
app:layout_constraintTop_toBottomOf="@id/auth_method" />
app:layout_constraintTop_toBottomOf="@id/smtp_security" />
<Spinner
android:id="@+id/cert_check"
+10 -1
View File
@@ -654,6 +654,7 @@
<string name="login_smtp_server">SMTP Server</string>
<string name="login_smtp_port">SMTP Port</string>
<string name="login_smtp_security">SMTP Security</string>
<!-- deprecated -->
<string name="login_auth_method">Authorization Method</string>
<!-- the word "Proxy" might be left untranslated unless the destination language has a well-known term for a "Proxy Server", acting intermediary between the app and the server -->
<string name="proxy_settings">Proxy</string>
@@ -668,8 +669,12 @@
<string name="proxy_use_proxy_confirm">Do you want to use proxy \"%1$s\"?</string>
<string name="proxy_share_explain">Your friends can add this proxy by scanning the QR code.</string>
<string name="proxy_share_link">Share Link</string>
<string name="proxy_enabled">Proxy Enabled</string>
<string name="proxy_enabled_hint">You are using a proxy. If you\'re having trouble connecting, try a different proxy.</string>
<!-- deprecated -->
<string name="login_info_oauth2_title">Continue with simplified setup?</string>
<!-- deprecated -->
<string name="login_info_oauth2_text">The entered address supports a simplified setup (OAuth 2.0).\n\nIn the next step, please allow Delta Chat to send and receive messages.\n\nDelta Chat does not collect user data, everything stays on your device.</string>
<string name="login_certificate_checks">Certificate Checks</string>
<string name="login_error_mail">Please enter a valid e-mail address</string>
@@ -775,7 +780,8 @@
<string name="pref_backup">Backup</string>
<string name="pref_backup_explain">Back Up Chats to External Storage</string>
<string name="pref_backup_export_explain">A backup helps you to set up a new installation on this or on another device.\n\nThe backup will contain all messages, contacts and chats and your end-to-end Autocrypt setup. Keep the backup file in a safe place or delete it as soon as possible.</string>
<!-- the placeholder will be replaced by the profile name -->
<string name="pref_backup_export_this">Export this profile</string>
<!-- deprecated -->
<string name="pref_backup_export_x">Export %1$s</string>
<!-- the placeholder will be replaced by the number of profiles to export; the number is always larger than 1 -->
<string name="pref_backup_export_all">Export all %1$d profiles</string>
@@ -789,6 +795,7 @@
<string name="pref_background_btn_default">Use Default Image</string>
<string name="pref_background_btn_gallery">Select From Gallery</string>
<string name="pref_imap_folder_warn_disable_defaults">If you change this option, make sure, your server and your other clients are configured accordingly.\n\nOtherwise things may not work at all.</string>
<!-- deprecated -->
<string name="pref_watch_sent_folder">Watch Sent Folder</string>
<string name="pref_send_copy_to_self">Send Copy to Self</string>
<string name="pref_send_copy_to_self_explain">Required when using this account on multiple devices.</string>
@@ -882,6 +889,7 @@
<string name="autocrypt_prefer_e2ee">Prefer End-To-End Encryption</string>
<!-- system messages -->
<!-- deprecated -->
<string name="systemmsg_unknown_sender_for_chat">Unknown sender for this chat. See \'info\' for more details.</string>
<string name="systemmsg_subject_for_new_contact">Message from %1$s</string>
<string name="systemmsg_failed_sending_to">Failed to send message to %1$s.</string>
@@ -1020,6 +1028,7 @@
<string name="verified_by">Introduced by %1$s</string>
<string name="verified_by_you">Introduced by me</string>
<string name="verified_by_unknown">Introduced</string>
<!-- deprecated -->
<string name="verified_contact_required_explain">To guarantee end-to-end-encryption, you can only add contacts with a green checkmark to this group.\n\nYou may meet contacts in person and scan their QR Code to introduce them.</string>
<string name="mailto_dialog_header_select_chat">Select chat to send the message to</string>
<!-- first placeholder is the name of the chat -->
@@ -88,11 +88,6 @@
android:entries="@array/pref_show_emails_entries"
android:entryValues="@array/pref_show_emails_values" />
<org.thoughtcrime.securesms.components.SwitchPreferenceCompat
android:defaultValue="true"
android:key="pref_sentbox_watch"
android:title="@string/pref_watch_sent_folder"/>
<org.thoughtcrime.securesms.components.SwitchPreferenceCompat
android:defaultValue="true"
android:key="pref_bcc_self"