mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
send broadcast to request account data if no account has been yet configured
This commit is contained in:
@@ -52,6 +52,7 @@ 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 boolean manualConfigure = true; // false: configure by QR account creation
|
||||
private ProgressDialog progressDialog = null;
|
||||
@@ -77,6 +78,16 @@ public class WelcomeActivity extends BaseActionBarActivity implements DcEventCen
|
||||
DcEventCenter eventCenter = DcHelper.getEventCenter(this);
|
||||
eventCenter.addObserver(DcContext.DC_EVENT_CONFIGURE_PROGRESS, this);
|
||||
eventCenter.addObserver(DcContext.DC_EVENT_IMEX_PROGRESS, this);
|
||||
|
||||
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("org.cyberta");
|
||||
intent.setAction(DC_REQUEST_ACCOUNT_DATA);
|
||||
sendBroadcast(intent);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -81,11 +81,23 @@ 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 int getInt(Context context, String key) {
|
||||
DcContext dcContext = getContext(context);
|
||||
return dcContext.getConfigInt(key);
|
||||
|
||||
Reference in New Issue
Block a user