[or-cvs] r21778: {projects} improved activate button responsive to be more instant (in projects/android/trunk/Orbot/src/org/torproject/android: . service)
Nathan Freitas
nathan at freitas.net
Mon Mar 1 06:15:35 UTC 2010
Author: n8fr8
Date: 2010-03-01 06:15:35 +0000 (Mon, 01 Mar 2010)
New Revision: 21778
Modified:
projects/android/trunk/Orbot/src/org/torproject/android/Orbot.java
projects/android/trunk/Orbot/src/org/torproject/android/service/TorService.java
Log:
improved activate button responsive to be more instant
Modified: projects/android/trunk/Orbot/src/org/torproject/android/Orbot.java
===================================================================
--- projects/android/trunk/Orbot/src/org/torproject/android/Orbot.java 2010-03-01 05:53:31 UTC (rev 21777)
+++ projects/android/trunk/Orbot/src/org/torproject/android/Orbot.java 2010-03-01 06:15:35 UTC (rev 21778)
@@ -631,39 +631,37 @@
{
try
{
+
if (mService == null)
{
}
else if (mService.getStatus() == STATUS_READY)
{
+
mService.setProfile(PROFILE_ON); //this means turn on
- updateStatus("");
+ imgStatus.setImageResource(R.drawable.torstarting);
+ lblStatus.setText(getString(R.string.status_starting_up));
+
+ Message msg = mHandler.obtainMessage(ENABLE_TOR_MSG);
+ mHandler.sendMessage(msg);
+
+ updateStatus("");
- processSettings();
-
-
- if (hasRoot && enableTransparentProxy)
- {
-
- TorTransProxy.setDNSProxying();
- TorTransProxy.setTransparentProxying(this,TorServiceUtils.getApps(this));
- }
}
else
{
mService.setProfile(PROFILE_ONDEMAND); //these means turn off
- updateStatus("");
- if (hasRoot && enableTransparentProxy)
- {
- TorTransProxy.purgeNatIptables();
- //TorRoot.setDNSProxying(false);
- //TorRoot.setTransparentProxying(this,false);
- }
+ Message msg = mHandler.obtainMessage(DISABLE_TOR_MSG);
+ mHandler.sendMessage(msg);
+
+ updateStatus("");
+
}
+
}
catch (Exception e)
{
@@ -675,6 +673,31 @@
}
+ private void doTorSetup (boolean enabled)
+ {
+ if (enabled)
+ {
+ processSettings();
+
+
+ if (hasRoot && enableTransparentProxy)
+ {
+
+ TorTransProxy.setDNSProxying();
+ TorTransProxy.setTransparentProxying(this,TorServiceUtils.getApps(this));
+ }
+ }
+ else
+ {
+ if (hasRoot && enableTransparentProxy)
+ {
+ TorTransProxy.purgeNatIptables();
+ //TorRoot.setDNSProxying(false);
+ //TorRoot.setTransparentProxying(this,false);
+ }
+ }
+ }
+
/**
* This implementation is used to receive callbacks from the remote
* service.
@@ -697,6 +720,8 @@
private static final int BUMP_MSG = 1;
+ private static final int ENABLE_TOR_MSG = 2;
+ private static final int DISABLE_TOR_MSG = 3;
private Handler mHandler = new Handler() {
@Override public void handleMessage(Message msg) {
@@ -711,6 +736,15 @@
updateStatus(torServiceMsg);
break;
+ case ENABLE_TOR_MSG:
+
+ doTorSetup(true);
+ break;
+ case DISABLE_TOR_MSG:
+
+ doTorSetup(false);
+ break;
+
default:
super.handleMessage(msg);
}
Modified: projects/android/trunk/Orbot/src/org/torproject/android/service/TorService.java
===================================================================
--- projects/android/trunk/Orbot/src/org/torproject/android/service/TorService.java 2010-03-01 05:53:31 UTC (rev 21777)
+++ projects/android/trunk/Orbot/src/org/torproject/android/service/TorService.java 2010-03-01 06:15:35 UTC (rev 21778)
@@ -699,6 +699,8 @@
public void setProfile (int profile)
{
setTorProfile(profile);
+ sendCallbackMessage("");
+
}
};
More information about the tor-commits
mailing list