mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
Merge pull request #4107 from deltachat/adb/improve-add-relay-workflow
improve UX of adding new relays via QR or clicking links
This commit is contained in:
@@ -50,6 +50,7 @@ import org.thoughtcrime.securesms.profiles.AvatarHelper;
|
||||
import org.thoughtcrime.securesms.proxy.ProxySettingsActivity;
|
||||
import org.thoughtcrime.securesms.qr.RegistrationQrActivity;
|
||||
import org.thoughtcrime.securesms.relay.EditRelayActivity;
|
||||
import org.thoughtcrime.securesms.relay.RelayListActivity;
|
||||
import org.thoughtcrime.securesms.scribbles.ScribbleActivity;
|
||||
import org.thoughtcrime.securesms.util.IntentUtils;
|
||||
import org.thoughtcrime.securesms.util.Prefs;
|
||||
@@ -106,11 +107,18 @@ public class InstantOnboardingActivity extends BaseActionBarActivity implements
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
boolean fromWelcome = getIntent().getBooleanExtra(FROM_WELCOME, false);
|
||||
|
||||
if (DcHelper.getContext(this).isConfigured() == 1) {
|
||||
// if account is configured it means we didn't come from Welcome screen nor from QR scanner,
|
||||
// instead, user clicked a dcaccount:// URI directly, so we need to switch to a new account:
|
||||
AccountManager.getInstance().beginAccountCreation(this);
|
||||
// instead, user clicked a dcaccount:// URI directly, so we need to just offer to add a new relay
|
||||
Intent intent = new Intent(this, RelayListActivity.class);
|
||||
String qrData = getIntent().getData().toString();
|
||||
intent.putExtra(RelayListActivity.EXTRA_QR_DATA, qrData);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(!fromWelcome) {
|
||||
@Override
|
||||
public void handleOnBackPressed() {
|
||||
|
||||
@@ -17,6 +17,7 @@ import org.thoughtcrime.securesms.ConversationActivity;
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.connect.AccountManager;
|
||||
import org.thoughtcrime.securesms.connect.DcHelper;
|
||||
import org.thoughtcrime.securesms.relay.RelayListActivity;
|
||||
import org.thoughtcrime.securesms.util.IntentUtils;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
import org.thoughtcrime.securesms.util.views.ProgressDialog;
|
||||
@@ -282,7 +283,16 @@ public class QrCodeHandler {
|
||||
Util.runOnMain(() -> {
|
||||
if (!progressDialog.isShowing()) return; // canceled dialog, nothing to do
|
||||
if (finalError != null) {
|
||||
Toast.makeText(activity, finalError, Toast.LENGTH_LONG).show();
|
||||
new AlertDialog.Builder(activity)
|
||||
.setTitle(R.string.error)
|
||||
.setMessage(finalError)
|
||||
.setPositiveButton(R.string.ok, null)
|
||||
.show();
|
||||
} else {
|
||||
showDoneToast(activity);
|
||||
if (!(activity instanceof RelayListActivity)) {
|
||||
activity.startActivity(new Intent(activity, RelayListActivity.class));
|
||||
}
|
||||
}
|
||||
try {
|
||||
progressDialog.dismiss();
|
||||
|
||||
@@ -37,6 +37,7 @@ public class RelayListActivity extends BaseActionBarActivity
|
||||
implements RelayListAdapter.OnRelayClickListener, DcEventCenter.DcEventDelegate {
|
||||
|
||||
private static final String TAG = RelayListActivity.class.getSimpleName();
|
||||
public static final String EXTRA_QR_DATA = "qr_data";
|
||||
|
||||
private RelayListAdapter adapter;
|
||||
private Rpc rpc;
|
||||
@@ -83,6 +84,12 @@ public class RelayListActivity extends BaseActionBarActivity
|
||||
|
||||
DcEventCenter eventCenter = DcHelper.getEventCenter(this);
|
||||
eventCenter.addObserver(DcContext.DC_EVENT_CONFIGURE_PROGRESS, this);
|
||||
|
||||
String qrdata = getIntent().getStringExtra(EXTRA_QR_DATA);
|
||||
if (qrdata != null) {
|
||||
QrCodeHandler qrCodeHandler = new QrCodeHandler(this);
|
||||
qrCodeHandler.handleQrData(qrdata);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user