diff --git a/src/org/torproject/android/OrbotMainActivity.java b/src/org/torproject/android/OrbotMainActivity.java index 786849a8..e9c96998 100644 --- a/src/org/torproject/android/OrbotMainActivity.java +++ b/src/org/torproject/android/OrbotMainActivity.java @@ -87,7 +87,7 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon private Toolbar mToolbar; /* Some tracking bits */ - private int torStatus = TorServiceConstants.STATUS_OFF; //latest status reported from the tor service + private String torStatus = TorServiceConstants.STATUS_OFF; //latest status reported from the tor service private SharedPreferences mPrefs = null; @@ -178,7 +178,7 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon } else if (intent.hasExtra("status")) { - torStatus = intent.getIntExtra("status", TorServiceConstants.STATUS_OFF); + torStatus = intent.getStringExtra("status"); updateStatus(""); } diff --git a/src/org/torproject/android/service/TorService.java b/src/org/torproject/android/service/TorService.java index 195fe98f..7a97e70a 100644 --- a/src/org/torproject/android/service/TorService.java +++ b/src/org/torproject/android/service/TorService.java @@ -84,7 +84,7 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon public static boolean ENABLE_DEBUG_LOG = true; - private int mCurrentStatus = STATUS_OFF; + private String mCurrentStatus = STATUS_OFF; private final static int CONTROL_SOCKET_TIMEOUT = 0; @@ -223,14 +223,10 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon } - - public int getTorStatus () - { - + public String getTorStatus() { return mCurrentStatus; - } - + private void clearNotifications () { if (mNotificationManager != null) @@ -1427,7 +1423,7 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon } - public void setTorProfile(int newState) { + public void setTorProfile(String newState) { if (newState == STATUS_ON) { @@ -2111,17 +2107,13 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon } - private void sendCallbackStatus (int currentStatus) - { - - - Intent intent = new Intent("status"); - // You can also include some extra data. - intent.putExtra("status", currentStatus); - LocalBroadcastManager.getInstance(this).sendBroadcast(intent); + private void sendCallbackStatus(String currentStatus) { + Intent intent = new Intent("status"); // TODO rename to proper action + // You can also include some extra data. + intent.putExtra("status", currentStatus); + LocalBroadcastManager.getInstance(this).sendBroadcast(intent); } - /* * Another way to do this would be to use the Observer pattern by defining the diff --git a/src/org/torproject/android/service/TorServiceConstants.java b/src/org/torproject/android/service/TorServiceConstants.java index 55ff6c3b..29ac47bf 100644 --- a/src/org/torproject/android/service/TorServiceConstants.java +++ b/src/org/torproject/android/service/TorServiceConstants.java @@ -66,10 +66,11 @@ public interface TorServiceConstants { //control port public final static String TOR_CONTROL_PORT_MSG_BOOTSTRAP_DONE = "Bootstrapped 100%"; - - public final static int STATUS_OFF = 0; - public final static int STATUS_ON = 1; - public final static int STATUS_CONNECTING = 2; + + public final static String STATUS_OFF = "OFF"; + public final static String STATUS_ON = "ON"; + public final static String STATUS_CONNECTING = "CONNECTING"; + public final static String STATUS_DISCONNECTING = "DISCONNECTING"; public static final int STATUS_MSG = 1; public static final int ENABLE_TOR_MSG = 2;