mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
Merge pull request #3334 from deltachat/adb/issue-3316
allow to set proxies from QRs
This commit is contained in:
@@ -263,6 +263,11 @@ public class DcContext {
|
||||
return oauth2url.startsWith("https://accounts.google.com/");
|
||||
}
|
||||
|
||||
public void restartIo() {
|
||||
stopIo();
|
||||
startIo();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if at least one chat has location streaming enabled
|
||||
*/
|
||||
|
||||
@@ -58,7 +58,7 @@ public class ProxySettingsActivity extends BaseActionBarActivity
|
||||
showAddProxyDialog();
|
||||
} else {
|
||||
DcHelper.set(this, CONFIG_PROXY_ENABLED, proxySwitch.isChecked()? "1" : "0");
|
||||
restartIO();
|
||||
DcHelper.getContext(this).restartIo();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -96,7 +96,7 @@ public class ProxySettingsActivity extends BaseActionBarActivity
|
||||
@Override
|
||||
public void onItemClick(String proxyUrl) {
|
||||
if (DcHelper.getContext(this).setConfigFromQr(proxyUrl)) {
|
||||
restartIO();
|
||||
DcHelper.getContext(this).restartIo();
|
||||
adapter.setSelectedProxy(proxyUrl);
|
||||
proxySwitch.setChecked(DcHelper.getInt(this, CONFIG_PROXY_ENABLED) == 1);
|
||||
} else {
|
||||
@@ -137,7 +137,7 @@ public class ProxySettingsActivity extends BaseActionBarActivity
|
||||
}
|
||||
String proxyUrls = String.join("\n", proxies);
|
||||
DcHelper.set(this, CONFIG_PROXY_URL, proxyUrls);
|
||||
restartIO();
|
||||
DcHelper.getContext(this).restartIo();
|
||||
adapter.changeData(proxyUrls);
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ public class ProxySettingsActivity extends BaseActionBarActivity
|
||||
final DcLot qrParsed = dcContext.checkQr(newProxy);
|
||||
if (qrParsed.getState() == DcContext.DC_QR_PROXY) {
|
||||
dcContext.setConfigFromQr(newProxy);
|
||||
restartIO();
|
||||
DcHelper.getContext(this).restartIo();
|
||||
adapter.changeData(DcHelper.get(this, CONFIG_PROXY_URL));
|
||||
} else {
|
||||
Toast.makeText(this, R.string.proxy_invalid, Toast.LENGTH_LONG).show();
|
||||
@@ -173,12 +173,6 @@ public class ProxySettingsActivity extends BaseActionBarActivity
|
||||
.show();
|
||||
}
|
||||
|
||||
private void restartIO() {
|
||||
DcContext dcContext = DcHelper.getContext(this);
|
||||
dcContext.stopIo();
|
||||
dcContext.startIo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleEvent(@NonNull DcEvent event) {
|
||||
if (event.getId() == DcContext.DC_EVENT_CONNECTIVITY_CHANGED) {
|
||||
|
||||
@@ -89,6 +89,17 @@ public class QrCodeHandler {
|
||||
BackupTransferActivity.appendSSID(activity, alertDialog.findViewById(android.R.id.message));
|
||||
return;
|
||||
|
||||
case DcContext.DC_QR_PROXY:
|
||||
builder.setTitle(R.string.proxy_use_proxy);
|
||||
builder.setMessage(activity.getString(R.string.proxy_use_proxy_confirm, qrParsed.getText1()));
|
||||
builder.setPositiveButton(R.string.proxy_use_proxy, (dlg, btn) -> {
|
||||
dcContext.setConfigFromQr(rawString);
|
||||
dcContext.restartIo();
|
||||
});
|
||||
builder.setNegativeButton(R.string.cancel, null);
|
||||
builder.setCancelable(false);
|
||||
break;
|
||||
|
||||
case DcContext.DC_QR_WEBRTC:
|
||||
builder.setMessage(activity.getString(R.string.videochat_instance_from_qr, qrParsed.getText1()));
|
||||
builder.setPositiveButton(R.string.ok, (dialog, which) -> {
|
||||
|
||||
Reference in New Issue
Block a user