Merge branch 'explain-tor-setting' into 'master'

Longer explanatory text for Tor mobile data setting



See merge request !29
This commit is contained in:
akwizgran
2015-12-17 16:56:27 +00:00
2 changed files with 28 additions and 10 deletions

View File

@@ -103,7 +103,9 @@
<string name="bluetooth_setting_enabled">Whenever contacts are nearby</string>
<string name="bluetooth_setting_disabled">Only when adding contacts</string>
<string name="tor_wifi_setting_title">TOR</string>
<string name="tor_wifi_setting"> Use Tor over WiFi Only</string>
<string name="tor_wifi_setting">Connect via Tor</string>
<string name="tor_wifi_setting_enabled">Only when using Wi-Fi</string>
<string name="tor_wifi_setting_disabled">When using Wi-Fi or mobile data</string>
<string name="notification_settings_title">NOTIFICATIONS</string>
<string name="notify_private_messages_setting">Show alerts for private messages</string>
<string name="notify_forum_posts_setting">Show alerts for forum posts</string>

View File

@@ -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);