mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-11 18:29:05 +01:00
Show reason why Tor is disabled.
This commit is contained in:
@@ -53,6 +53,7 @@ import static java.util.logging.Level.WARNING;
|
||||
import static java.util.logging.Logger.getLogger;
|
||||
import static org.briarproject.bramble.api.plugin.Plugin.PREF_PLUGIN_ENABLE;
|
||||
import static org.briarproject.bramble.api.plugin.Plugin.State.ACTIVE;
|
||||
import static org.briarproject.bramble.api.plugin.Plugin.State.DISABLED;
|
||||
import static org.briarproject.bramble.api.plugin.Plugin.State.STARTING_STOPPING;
|
||||
import static org.briarproject.bramble.util.LogUtils.logDuration;
|
||||
import static org.briarproject.bramble.util.LogUtils.logException;
|
||||
@@ -354,6 +355,10 @@ class PluginManagerImpl implements PluginManager, Service {
|
||||
} else if (oldState == ACTIVE) {
|
||||
eventBus.broadcast(new TransportInactiveEvent(id));
|
||||
}
|
||||
} else if (newState == DISABLED) {
|
||||
// Broadcast an event even though the state hasn't changed, as
|
||||
// the reasons for the plugin being disabled may have changed
|
||||
eventBus.broadcast(new TransportStateEvent(id, newState));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -162,6 +162,11 @@ public class PluginViewModel extends AndroidViewModel implements EventListener {
|
||||
return bluetoothTurnedOn;
|
||||
}
|
||||
|
||||
int getReasonsTorDisabled() {
|
||||
Plugin plugin = pluginManager.getPlugin(TorConstants.ID);
|
||||
return plugin == null ? 0 : plugin.getReasonsDisabled();
|
||||
}
|
||||
|
||||
void enableTransport(TransportId id, boolean enable) {
|
||||
Settings s = new Settings();
|
||||
s.putBoolean(PREF_PLUGIN_ENABLE, enable);
|
||||
|
||||
@@ -47,6 +47,9 @@ import static org.briarproject.bramble.api.plugin.Plugin.State.ACTIVE;
|
||||
import static org.briarproject.bramble.api.plugin.Plugin.State.DISABLED;
|
||||
import static org.briarproject.bramble.api.plugin.Plugin.State.ENABLING;
|
||||
import static org.briarproject.bramble.api.plugin.Plugin.State.STARTING_STOPPING;
|
||||
import static org.briarproject.bramble.api.plugin.TorConstants.REASON_BATTERY;
|
||||
import static org.briarproject.bramble.api.plugin.TorConstants.REASON_COUNTRY_BLOCKED;
|
||||
import static org.briarproject.bramble.api.plugin.TorConstants.REASON_MOBILE_DATA;
|
||||
|
||||
@MethodsNotNullByDefault
|
||||
@ParametersNotNullByDefault
|
||||
@@ -253,10 +256,24 @@ public class TransportsActivity extends BriarActivity {
|
||||
|
||||
@StringRes
|
||||
private int getTorPluginStatus(State state) {
|
||||
if (state == ENABLING) return R.string.tor_plugin_status_enabling;
|
||||
else if (state == ACTIVE) return R.string.tor_plugin_status_active;
|
||||
else if (state == DISABLED) return R.string.tor_plugin_status_disabled;
|
||||
else return R.string.tor_plugin_status_inactive;
|
||||
if (state == ENABLING) {
|
||||
return R.string.tor_plugin_status_enabling;
|
||||
} else if (state == ACTIVE) {
|
||||
return R.string.tor_plugin_status_active;
|
||||
} else if (state == DISABLED) {
|
||||
int reasons = viewModel.getReasonsTorDisabled();
|
||||
if ((reasons & REASON_MOBILE_DATA) != 0) {
|
||||
return R.string.tor_plugin_status_disabled_mobile_data;
|
||||
} else if ((reasons & REASON_BATTERY) != 0) {
|
||||
return R.string.tor_plugin_status_disabled_battery;
|
||||
} else if ((reasons & REASON_COUNTRY_BLOCKED) != 0) {
|
||||
return R.string.tor_plugin_status_disabled_country_blocked;
|
||||
} else {
|
||||
return R.string.tor_plugin_status_disabled;
|
||||
}
|
||||
} else {
|
||||
return R.string.tor_plugin_status_inactive;
|
||||
}
|
||||
}
|
||||
|
||||
@StringRes
|
||||
|
||||
@@ -79,6 +79,9 @@
|
||||
<string name="tor_plugin_status_active">Briar is connected to the Internet</string>
|
||||
<string name="tor_plugin_status_inactive">Briar can\'t connect to the Internet</string>
|
||||
<string name="tor_plugin_status_disabled">Briar is configured not to use the Internet</string>
|
||||
<string name="tor_plugin_status_disabled_mobile_data">Briar is configured not to use mobile data</string>
|
||||
<string name="tor_plugin_status_disabled_battery">Briar is configured not to use the Internet when running on battery</string>
|
||||
<string name="tor_plugin_status_disabled_country_blocked">Briar is configured not to use the Internet in this country</string>
|
||||
|
||||
<!-- Transports: Wi-Fi -->
|
||||
<string name="transport_lan">Wi-Fi</string>
|
||||
|
||||
Reference in New Issue
Block a user