mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 11:19:04 +01:00
Show reason why Tor is disabled.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user