mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 11:19:04 +01:00
[plugins/tor/TorPlugin] Adds tor-over-wifi setting
Provides a checkbox in the settings view, as well as an event handler to disable/enable the tor network if the device is not on using the wifi connection. Refactors network-enabling code to a separate function. This function is ran after the network state changes, or the settings change and will update the status accordingly.
This commit is contained in:
@@ -67,6 +67,7 @@ OnClickListener {
|
||||
private TextView enableBluetooth = null, enableBluetoothHint = null;
|
||||
private CheckBox notifyPrivateMessages = null, notifyGroupPosts = null;
|
||||
private CheckBox notifyVibration = null;
|
||||
private CheckBox torOverWifi = null;
|
||||
private TextView notifySound = null, notifySoundHint = null;
|
||||
private ListLoadingProgressBar progress = null;
|
||||
private ImageButton testingButton = null;
|
||||
@@ -117,6 +118,23 @@ OnClickListener {
|
||||
enableBluetoothHint.setOnClickListener(this);
|
||||
settings.addView(enableBluetoothHint);
|
||||
|
||||
TextView torTitle = new TextView(this);
|
||||
torTitle.setPadding(pad, 0, pad, 0);
|
||||
torTitle.setTypeface(DEFAULT_BOLD);
|
||||
torTitle.setTextColor(titleText);
|
||||
torTitle.setText(R.string.tor_wifi_setting_title);
|
||||
settings.addView(torTitle);
|
||||
|
||||
underline = new HorizontalBorder(this);
|
||||
underline.setBackgroundColor(titleUnderline);
|
||||
settings.addView(underline);
|
||||
|
||||
torOverWifi = new CheckBox(this);
|
||||
torOverWifi.setTextSize(18);
|
||||
torOverWifi.setText(R.string.tor_wifi_setting);
|
||||
torOverWifi.setOnClickListener(this);
|
||||
settings.addView(torOverWifi);
|
||||
|
||||
TextView notificationsTitle = new TextView(this);
|
||||
notificationsTitle.setPadding(pad, 0, pad, 0);
|
||||
notificationsTitle.setTypeface(DEFAULT_BOLD);
|
||||
@@ -280,6 +298,8 @@ OnClickListener {
|
||||
}
|
||||
storeBluetoothSetting();
|
||||
displaySettings();
|
||||
} else if (view == torOverWifi) {
|
||||
storeTorSettings();
|
||||
} else if (view == notifyPrivateMessages) {
|
||||
Settings s = new Settings();
|
||||
s.putBoolean("notifyPrivateMessages",
|
||||
@@ -312,6 +332,24 @@ 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 {
|
||||
db.mergeConfig(new TransportId("tor"), c);
|
||||
} catch (DbException e) {
|
||||
if (LOG.isLoggable(WARNING))
|
||||
LOG.log(WARNING, e.toString(), e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void storeBluetoothSetting() {
|
||||
runOnDbThread(new Runnable() {
|
||||
public void run() {
|
||||
|
||||
Reference in New Issue
Block a user