mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
Merge branch 'main' into adb/issue-3963
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
+3
-3
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user