diff --git a/briar-android/res/values/strings.xml b/briar-android/res/values/strings.xml
index bdcf26104..fe43fd7c2 100644
--- a/briar-android/res/values/strings.xml
+++ b/briar-android/res/values/strings.xml
@@ -103,7 +103,9 @@
Whenever contacts are nearby
Only when adding contacts
TOR
- Use Tor over WiFi Only
+ Connect via Tor
+ Only when using Wi-Fi
+ When using Wi-Fi or mobile data
NOTIFICATIONS
Show alerts for private messages
Show alerts for forum posts
diff --git a/briar-android/src/org/briarproject/android/SettingsActivity.java b/briar-android/src/org/briarproject/android/SettingsActivity.java
index 0fd88f46d..e2f2d233a 100644
--- a/briar-android/src/org/briarproject/android/SettingsActivity.java
+++ b/briar-android/src/org/briarproject/android/SettingsActivity.java
@@ -67,7 +67,7 @@ OnClickListener {
private TextView enableBluetooth = null, enableBluetoothHint = null;
private CheckBox notifyPrivateMessages = null, notifyForumPosts = null;
private CheckBox notifyVibration = null;
- private CheckBox torOverWifi = null;
+ private TextView torOverWifi = null, torOverWifiHint = null;
private TextView notifySound = null, notifySoundHint = null;
private ListLoadingProgressBar progress = null;
private ImageButton testingButton = null;
@@ -76,7 +76,7 @@ OnClickListener {
@Inject private volatile DatabaseComponent db;
@Inject private volatile EventBus eventBus;
private volatile Settings settings;
- private volatile boolean bluetoothSetting = true;
+ private volatile boolean bluetoothSetting = true, torSetting = false;
@Override
public void onCreate(Bundle state) {
@@ -129,12 +129,18 @@ OnClickListener {
underline.setBackgroundColor(titleUnderline);
settings.addView(underline);
- torOverWifi = new CheckBox(this);
+ torOverWifi = new TextView(this);
+ torOverWifi.setPadding(pad, pad, pad, 0);
torOverWifi.setTextSize(18);
torOverWifi.setText(R.string.tor_wifi_setting);
torOverWifi.setOnClickListener(this);
settings.addView(torOverWifi);
+ torOverWifiHint = new TextView(this);
+ torOverWifiHint.setPadding(pad, 0, pad, pad);
+ torOverWifiHint.setOnClickListener(this);
+ settings.addView(torOverWifiHint);
+
TextView notificationsTitle = new TextView(this);
notificationsTitle.setPadding(pad, 0, pad, 0);
notificationsTitle.setTypeface(DEFAULT_BOLD);
@@ -236,6 +242,7 @@ OnClickListener {
if (LOG.isLoggable(INFO))
LOG.info("Loading settings took " + duration + " ms");
bluetoothSetting = c.getBoolean("enable", false);
+ torSetting = settings.getBoolean("torOverWifi", false);
displaySettings();
} catch (DbException e) {
if (LOG.isLoggable(WARNING))
@@ -256,6 +263,10 @@ OnClickListener {
else resId = R.string.bluetooth_setting_disabled;
enableBluetoothHint.setText(resId);
+ if (torSetting) resId = R.string.tor_wifi_setting_enabled;
+ else resId = R.string.tor_wifi_setting_disabled;
+ torOverWifiHint.setText(resId);
+
notifyPrivateMessages.setChecked(settings.getBoolean(
"notifyPrivateMessages", true));
@@ -298,7 +309,8 @@ OnClickListener {
}
storeBluetoothSetting();
displaySettings();
- } else if (view == torOverWifi) {
+ } else if (view == torOverWifi || view == torOverWifiHint) {
+ torSetting = !torSetting;
storeTorSettings();
} else if (view == notifyPrivateMessages) {
Settings s = new Settings();
@@ -335,13 +347,17 @@ OnClickListener {
private void storeTorSettings() {
runOnDbThread(new Runnable() {
public void run() {
- Settings s = new Settings();
- s.putBoolean("torOverWifi", torOverWifi.isChecked());
- TransportConfig c = new TransportConfig();
- c.putBoolean("torOverWifi", torOverWifi.isChecked());
- storeSettings(s);
try {
+ Settings s = new Settings();
+ s.putBoolean("torOverWifi", torSetting);
+ TransportConfig c = new TransportConfig();
+ c.putBoolean("torOverWifi", torSetting);
+ long now = System.currentTimeMillis();
+ db.mergeSettings(s);
db.mergeConfig(new TransportId("tor"), c);
+ long duration = System.currentTimeMillis() - now;
+ if (LOG.isLoggable(INFO))
+ LOG.info("Merging config took " + duration + " ms");
} catch (DbException e) {
if (LOG.isLoggable(WARNING))
LOG.log(WARNING, e.toString(), e);