use Tor to download map tiles if configured to do so
This commit is contained in:
parent
eb1251b389
commit
d5a187bafb
|
@ -77,7 +77,7 @@ public class HttpConnectionManager extends AbstractConnectionManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Proxy getProxy() throws IOException {
|
public static Proxy getProxy() throws IOException {
|
||||||
return new Proxy(Proxy.Type.HTTP, new InetSocketAddress(InetAddress.getByAddress(new byte[]{127,0,0,1}), 8118));
|
return new Proxy(Proxy.Type.HTTP, new InetSocketAddress(InetAddress.getByAddress(new byte[]{127,0,0,1}), 8118));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -222,7 +222,7 @@ public class HttpDownloadConnection implements Transferable {
|
||||||
changeStatus(STATUS_CHECKING);
|
changeStatus(STATUS_CHECKING);
|
||||||
HttpURLConnection connection;
|
HttpURLConnection connection;
|
||||||
if (mUseTor) {
|
if (mUseTor) {
|
||||||
connection = (HttpURLConnection) mUrl.openConnection(mHttpConnectionManager.getProxy());
|
connection = (HttpURLConnection) mUrl.openConnection(HttpConnectionManager.getProxy());
|
||||||
} else {
|
} else {
|
||||||
connection = (HttpURLConnection) mUrl.openConnection();
|
connection = (HttpURLConnection) mUrl.openConnection();
|
||||||
}
|
}
|
||||||
|
@ -290,7 +290,7 @@ public class HttpDownloadConnection implements Transferable {
|
||||||
try {
|
try {
|
||||||
wakeLock.acquire();
|
wakeLock.acquire();
|
||||||
if (mUseTor) {
|
if (mUseTor) {
|
||||||
connection = (HttpURLConnection) mUrl.openConnection(mHttpConnectionManager.getProxy());
|
connection = (HttpURLConnection) mUrl.openConnection(HttpConnectionManager.getProxy());
|
||||||
} else {
|
} else {
|
||||||
connection = (HttpURLConnection) mUrl.openConnection();
|
connection = (HttpURLConnection) mUrl.openConnection();
|
||||||
}
|
}
|
||||||
|
|
|
@ -180,7 +180,7 @@ public class HttpUploadConnection implements Transferable {
|
||||||
wakeLock.acquire(readTimeout);
|
wakeLock.acquire(readTimeout);
|
||||||
Log.d(Config.LOGTAG, "uploading to " + mPutUrl.toString()+ " w/ read timeout of "+readTimeout+"s");
|
Log.d(Config.LOGTAG, "uploading to " + mPutUrl.toString()+ " w/ read timeout of "+readTimeout+"s");
|
||||||
if (mUseTor) {
|
if (mUseTor) {
|
||||||
connection = (HttpURLConnection) mPutUrl.openConnection(mHttpConnectionManager.getProxy());
|
connection = (HttpURLConnection) mPutUrl.openConnection(HttpConnectionManager.getProxy());
|
||||||
} else {
|
} else {
|
||||||
connection = (HttpURLConnection) mPutUrl.openConnection();
|
connection = (HttpURLConnection) mPutUrl.openConnection();
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
import android.support.annotation.BoolRes;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
@ -29,10 +30,12 @@ import org.osmdroid.views.MapView;
|
||||||
import org.osmdroid.views.overlay.Overlay;
|
import org.osmdroid.views.overlay.Overlay;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
import eu.siacs.conversations.BuildConfig;
|
import eu.siacs.conversations.BuildConfig;
|
||||||
import eu.siacs.conversations.Config;
|
import eu.siacs.conversations.Config;
|
||||||
import eu.siacs.conversations.R;
|
import eu.siacs.conversations.R;
|
||||||
|
import eu.siacs.conversations.http.HttpConnectionManager;
|
||||||
import eu.siacs.conversations.ui.util.LocationHelper;
|
import eu.siacs.conversations.ui.util.LocationHelper;
|
||||||
import eu.siacs.conversations.ui.widget.Marker;
|
import eu.siacs.conversations.ui.widget.Marker;
|
||||||
import eu.siacs.conversations.ui.widget.MyLocation;
|
import eu.siacs.conversations.ui.widget.MyLocation;
|
||||||
|
@ -100,6 +103,13 @@ public abstract class LocationActivity extends ActionBarActivity implements Loca
|
||||||
final IConfigurationProvider config = Configuration.getInstance();
|
final IConfigurationProvider config = Configuration.getInstance();
|
||||||
config.load(ctx, getPreferences());
|
config.load(ctx, getPreferences());
|
||||||
config.setUserAgentValue(BuildConfig.APPLICATION_ID + "_" + BuildConfig.VERSION_CODE);
|
config.setUserAgentValue(BuildConfig.APPLICATION_ID + "_" + BuildConfig.VERSION_CODE);
|
||||||
|
if (Config.FORCE_ORBOT || getBooleanPreference("use_tor", R.bool.use_tor)) {
|
||||||
|
try {
|
||||||
|
config.setHttpProxy(HttpConnectionManager.getProxy());
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException("Unable to configure proxy");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final File f = new File(ctx.getCacheDir() + "/tiles");
|
final File f = new File(ctx.getCacheDir() + "/tiles");
|
||||||
try {
|
try {
|
||||||
|
@ -286,6 +296,10 @@ public abstract class LocationActivity extends ActionBarActivity implements Loca
|
||||||
return PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
return PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected boolean getBooleanPreference(String name, @BoolRes int res) {
|
||||||
|
return getPreferences().getBoolean(name, getResources().getBoolean(res));
|
||||||
|
}
|
||||||
|
|
||||||
protected boolean isLocationEnabled() {
|
protected boolean isLocationEnabled() {
|
||||||
try {
|
try {
|
||||||
final int locationMode = Settings.Secure.getInt(getContentResolver(), Settings.Secure.LOCATION_MODE);
|
final int locationMode = Settings.Secure.getInt(getContentResolver(), Settings.Secure.LOCATION_MODE);
|
||||||
|
|
|
@ -33,6 +33,7 @@ import android.os.IBinder;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
import android.support.annotation.BoolRes;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.support.v7.app.AlertDialog.Builder;
|
import android.support.v7.app.AlertDialog.Builder;
|
||||||
|
@ -399,7 +400,7 @@ public abstract class XmppActivity extends ActionBarActivity {
|
||||||
setTheme(this.mTheme);
|
setTheme(this.mTheme);
|
||||||
|
|
||||||
this.mUsingEnterKey = usingEnterKey();
|
this.mUsingEnterKey = usingEnterKey();
|
||||||
mUseSubject = getPreferences().getBoolean("use_subject", getResources().getBoolean(R.bool.use_subject));
|
mUseSubject = getBooleanPreference("use_subject", R.bool.use_subject);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isCameraFeatureAvailable() {
|
protected boolean isCameraFeatureAvailable() {
|
||||||
|
@ -449,6 +450,10 @@ public abstract class XmppActivity extends ActionBarActivity {
|
||||||
return PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
return PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected boolean getBooleanPreference(String name, @BoolRes int res) {
|
||||||
|
return getPreferences().getBoolean(name, getResources().getBoolean(res));
|
||||||
|
}
|
||||||
|
|
||||||
public boolean useSubjectToIdentifyConference() {
|
public boolean useSubjectToIdentifyConference() {
|
||||||
return mUseSubject;
|
return mUseSubject;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue