add button handle logic

This commit is contained in:
Nathan Freitas 2015-02-01 23:36:19 -05:00
parent 753e21f367
commit c1fe536aeb
2 changed files with 39 additions and 22 deletions

View File

@ -65,10 +65,10 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
private MenuItem mItemOnOff = null;
private TextView downloadText = null;
private TextView uploadText = null;
// private TextView mTxtOrbotLog = null;
// private SlidingDrawer mDrawer = null;
private boolean mDrawerOpen = false;
// private View mViewMain = null;
private Button mBtnBrowser = null;
private Button mBtnVPN = null;
/* Some tracking bits */
private int torStatus = TorServiceConstants.STATUS_OFF; //latest status reported from the tor service
@ -230,8 +230,8 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
// Gesture detection
mGestureDetector = new GestureDetector(this, new MyGestureDetector());
Button btnBrowser = (Button)findViewById(R.id.btnBrowser);
btnBrowser.setOnClickListener(new View.OnClickListener ()
mBtnBrowser = (Button)findViewById(R.id.btnBrowser);
mBtnBrowser.setOnClickListener(new View.OnClickListener ()
{
@Override
@ -243,8 +243,8 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
});
Button btnVPN = (Button)findViewById(R.id.btnVPN);
btnVPN.setOnClickListener(new View.OnClickListener ()
mBtnVPN = (Button)findViewById(R.id.btnVPN);
mBtnVPN.setOnClickListener(new View.OnClickListener ()
{
@Override
@ -401,10 +401,6 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
startActivity(new Intent(this, ChooseLocaleWizardActivity.class));
}
else if (item.getItemId() == R.id.menu_verify)
{
doTorCheck();
}
else if (item.getItemId() == R.id.menu_exit)
{
//exit app
@ -418,10 +414,16 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
}
/**
else if (item.getItemId() == R.id.menu_verify)
{
doTorCheck();
}
else if (item.getItemId() == R.id.menu_vpn)
{
startVpnService();
}
}*/
return true;
}
@ -901,6 +903,9 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
imgStatus.setImageResource(R.drawable.toron);
mBtnBrowser.setEnabled(true);
mBtnVPN.setEnabled(true);
String lblMsg = getString(R.string.status_activated);
//lblStatus.setText(lblMsg);
@ -962,6 +967,9 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
if (mItemOnOff != null)
mItemOnOff.setTitle(R.string.menu_start);
mBtnBrowser.setEnabled(false);
mBtnVPN.setEnabled(false);
}
}

View File

@ -114,16 +114,25 @@ public class OrbotVpnService extends VpnService implements Handler.Callback {
// (i.e., Farsi and Arabic).^M
Locale.setDefault(new Locale("en"));
String vpnName = "OrbotVPN";
String virtualGateway = "10.0.0.1";
String virtualRoute = "10.0.0.0";
String virtualIP = "10.0.0.2";
String virtualNetMask = "255.255.2555.0";
String localSocks = "localhost:" + TorServiceConstants.PORT_SOCKS_DEFAULT;
String localDNS = "localhost:" + TorServiceConstants.TOR_DNS_PORT_DEFAULT;
Builder builder = new Builder();
builder.setMtu(VPN_MTU);
builder.addAddress("10.0.0.1",8);
builder.setSession("OrbotVPN");
builder.addAddress(virtualGateway,8);
builder.setSession(vpnName);
builder.addRoute("0.0.0.0",0);
builder.addRoute("10.0.0.0",8);
//builder.addRoute("192.0.0.0",8);
//builder.addRoute("192.168.43.0",8);
builder.addDnsServer("8.8.8.8");
builder.addRoute(virtualRoute,8);
//builder.addDnsServer("8.8.8.8");
// Create a new interface using the builder and save the parameters.
mInterface = builder.setSession(mSessionName)
@ -132,7 +141,7 @@ public class OrbotVpnService extends VpnService implements Handler.Callback {
try
{
Tun2Socks.Start(mInterface, VPN_MTU, "10.0.0.2", "255.255.255.0", "localhost:" + TorServiceConstants.PORT_SOCKS_DEFAULT, "50.116.51.157:7300", true);
Tun2Socks.Start(mInterface, VPN_MTU, virtualIP, virtualNetMask, localSocks , localDNS , true);
}
catch (Exception e)
{
@ -170,7 +179,7 @@ public class OrbotVpnService extends VpnService implements Handler.Callback {
/*
private void debugPacket(ByteBuffer packet)
{
{b
int buffer = packet.get();
int version;