mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
Merge pull request #3981 from deltachat/adb/remove-companion-app-code
remove deprecated companion app
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
## Unreleased
|
||||
|
||||
* don't show badge counter in app icon for the permanent background notification
|
||||
* remove deprecated "companion app" code
|
||||
* fix sorting of old media in gallery
|
||||
|
||||
## v2.22.0
|
||||
|
||||
@@ -405,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">
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -220,21 +210,6 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve
|
||||
}
|
||||
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(); }
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -95,27 +95,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);
|
||||
|
||||
@@ -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