mirror of
https://github.com/deltachat/deltachat-android.git
synced 2025-10-05 02:29:24 +02:00
register app for opening ss:// and socks5:// proxy URLs
also linkify proxy URLs in text messages
This commit is contained in:
parent
6f3d8a4414
commit
8487c286e6
4 changed files with 66 additions and 2 deletions
|
@ -4,6 +4,7 @@ import static org.thoughtcrime.securesms.connect.DcHelper.CONFIG_PROXY_ENABLED;
|
|||
import static org.thoughtcrime.securesms.connect.DcHelper.CONFIG_PROXY_URL;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
|
@ -70,6 +71,14 @@ public class ProxySettingsActivity extends BaseActionBarActivity
|
|||
proxyList.addFooterView(footer);
|
||||
adapter.changeData(DcHelper.get(this, CONFIG_PROXY_URL));
|
||||
DcHelper.getEventCenter(this).addObserver(DcContext.DC_EVENT_CONNECTIVITY_CHANGED, this);
|
||||
|
||||
handleOpenProxyUrl();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNewIntent(Intent intent) {
|
||||
super.onNewIntent(intent);
|
||||
handleOpenProxyUrl();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -173,6 +182,34 @@ public class ProxySettingsActivity extends BaseActionBarActivity
|
|||
.show();
|
||||
}
|
||||
|
||||
private void handleOpenProxyUrl() {
|
||||
if (getIntent() != null && Intent.ACTION_VIEW.equals(getIntent().getAction())) {
|
||||
Uri uri = getIntent().getData();
|
||||
if (uri == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
DcContext dcContext = DcHelper.getContext(this);
|
||||
final DcLot qrParsed = dcContext.checkQr(uri.toString());
|
||||
if (qrParsed.getState() == DcContext.DC_QR_PROXY) {
|
||||
new AlertDialog.Builder(this)
|
||||
.setTitle(R.string.proxy_use_proxy)
|
||||
.setMessage(getString(R.string.proxy_use_proxy_confirm, qrParsed.getText1()))
|
||||
.setPositiveButton(R.string.proxy_use_proxy, (dlg, btn) -> {
|
||||
dcContext.setConfigFromQr(uri.toString());
|
||||
dcContext.restartIo();
|
||||
adapter.changeData(DcHelper.get(this, CONFIG_PROXY_URL));
|
||||
proxySwitch.setChecked(DcHelper.getInt(this, CONFIG_PROXY_ENABLED) == 1);
|
||||
})
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.setCancelable(false)
|
||||
.show();
|
||||
} else {
|
||||
Toast.makeText(this, R.string.proxy_invalid, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleEvent(@NonNull DcEvent event) {
|
||||
if (event.getId() == DcContext.DC_EVENT_CONNECTIVITY_CHANGED) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue