Commit 732bf6d4 authored by akwizgran's avatar akwizgran

Show countries where Tor is blocked.

parent 53762e7c
......@@ -43,6 +43,7 @@ import org.briarproject.briar.android.util.UiUtils;
import org.briarproject.briar.android.util.UserFeedback;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.logging.Logger;
......@@ -67,15 +68,19 @@ import static android.provider.Settings.EXTRA_CHANNEL_ID;
import static android.provider.Settings.System.DEFAULT_NOTIFICATION_URI;
import static android.support.v4.view.ViewCompat.LAYOUT_DIRECTION_LTR;
import static android.widget.Toast.LENGTH_SHORT;
import static java.util.Arrays.asList;
import static java.util.logging.Level.INFO;
import static java.util.logging.Level.WARNING;
import static org.briarproject.bramble.api.plugin.BluetoothConstants.PREF_BT_ENABLE;
import static org.briarproject.bramble.api.plugin.TorConstants.PREF_TOR_DISABLE_BLOCKED;
import static org.briarproject.bramble.api.plugin.TorConstants.PREF_TOR_NETWORK;
import static org.briarproject.bramble.api.plugin.TorConstants.PREF_TOR_NETWORK_ALWAYS;
import static org.briarproject.bramble.plugin.tor.CircumventionProvider.BLOCKED;
import static org.briarproject.bramble.plugin.tor.CircumventionProvider.BRIDGES;
import static org.briarproject.bramble.util.LogUtils.logDuration;
import static org.briarproject.bramble.util.LogUtils.logException;
import static org.briarproject.bramble.util.LogUtils.now;
import static org.briarproject.bramble.util.StringUtils.join;
import static org.briarproject.briar.android.TestingConstants.FEATURE_FLAG_DARK_THEME;
import static org.briarproject.briar.android.TestingConstants.FEATURE_FLAG_SIGN_IN_REMINDER;
import static org.briarproject.briar.android.TestingConstants.IS_DEBUG_BUILD;
......@@ -154,6 +159,7 @@ public class SettingsFragment extends PreferenceFragmentCompat
enableBluetooth = (ListPreference) findPreference("pref_key_bluetooth");
torNetwork = (ListPreference) findPreference("pref_key_tor_network");
torBlocked = (CheckBoxPreference) findPreference(TOR_LOCATION);
setBlockedCountries();
CheckBoxPreference notifySignIn =
(CheckBoxPreference) findPreference(NOTIFY_SIGN_IN);
notifyPrivateMessages = (CheckBoxPreference) findPreference(
......@@ -293,6 +299,14 @@ public class SettingsFragment extends PreferenceFragmentCompat
return direction == LAYOUT_DIRECTION_LTR;
}
private void setBlockedCountries() {
List<String> countries = new ArrayList<>(asList(BLOCKED));
countries.removeAll(asList(BRIDGES));
Collections.sort(countries);
String format = getString(R.string.tor_location_setting_hint_format);
torBlocked.setSummary(String.format(format, join(countries, ", ")));
}
private void loadSettings() {
listener.runOnDbThread(() -> {
try {
......
......@@ -349,7 +349,7 @@
<string name="tor_network_setting_wifi">Only when using Wi-Fi</string>
<string name="tor_network_setting_always">When using Wi-Fi or mobile data</string>
<string name="tor_location_setting_title">Disable Tor based on location</string>
<string name="tor_location_setting_hint">Disable Tor in countries where it is likely to be blocked</string>
<string name="tor_location_setting_hint_format">Disable Tor in countries where it is likely to be blocked (%1$s)</string>
<!-- Settings Security and Panic -->
<string name="security_settings_title">Security</string>
......
......@@ -48,7 +48,6 @@
android:defaultValue="true"
android:key="pref_key_tor_location"
android:persistent="false"
android:summary="@string/tor_location_setting_hint"
android:title="@string/tor_location_setting_title"/>
</PreferenceCategory>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment