more fixes for UI disconnect issue

ensure service and status updates occur on new layout updates
This commit is contained in:
Nathan Freitas 2014-06-11 07:07:48 -04:00
parent 7e76162b88
commit d7f3f1989d
1 changed files with 23 additions and 20 deletions

View File

@ -110,6 +110,7 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
{
Intent torService = new Intent(this, TorService.class);
/*
if (Build.VERSION.SDK_INT > 14)
{
@ -118,10 +119,10 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
}
else
{
*/
bindService(torService,
mConnection, Context.BIND_AUTO_CREATE);
}
//}
startService(torService);
@ -184,6 +185,7 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
// Gesture detection
mGestureDetector = new GestureDetector(this, new MyGestureDetector());
}
GestureDetector mGestureDetector;
@ -535,13 +537,6 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
}
@Override
protected void onNewIntent(Intent intent) {
setIntent(intent);
handleIntents();
}
private void handleIntents ()
{
if (getIntent() == null)
@ -674,6 +669,7 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
super.onConfigurationChanged(newConfig);
doLayout();
updateStatus("");
}
/* (non-Javadoc)
@ -800,18 +796,22 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
protected void onResume() {
super.onResume();
if (mService != null && torStatus != TorServiceConstants.STATUS_ON)
if (mService != null)
{
try {
mService.processSettings();
setLocale();
if (torStatus != TorServiceConstants.STATUS_ON)
mService.processSettings();
setLocale();
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
updateStatus("");
}
AlertDialog aDialog = null;
@ -901,8 +901,8 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
if (newTorStatus == TorServiceConstants.STATUS_ON)
{
if (torStatus != newTorStatus)
{
//if (torStatus != newTorStatus)
//{
imgStatus.setImageResource(R.drawable.toron);
// mViewMain.setBackgroundResource(R.drawable.onionrootonly);
@ -912,7 +912,7 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
if (mItemOnOff != null)
mItemOnOff.setTitle(R.string.menu_stop);
}
//}
if (mTorServiceMsg != null && mTorServiceMsg.length() > 0)
{
@ -1193,6 +1193,8 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
// representation of that from the raw service object.
mService = ITorService.Stub.asInterface(service);
torStatus = -1;
// We want to monitor the service for as long as we are
// connected to it.
try {
@ -1206,9 +1208,9 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
}
updateStatus("");
handleIntents();
updateStatus("");
} catch (RemoteException e) {
// In this case the service has crashed before we could even
@ -1229,7 +1231,7 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
// This is called when the connection with the service has been
// unexpectedly disconnected -- that is, its process crashed.
mService = null;
Log.d(TAG,"service was disconnected");
}
};
@ -1254,6 +1256,7 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
unbindService(mConnection);
mIsBound = false;
Log.d(TAG,"service was ubnound");
//maybe needs this?
mService = null;
@ -1310,7 +1313,7 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
protected void onDestroy() {
super.onDestroy();
unbindService();
//unbindService();
}
public class DataCount {