fix Service init/bind logic
also remove updates for background drawing to save memory
This commit is contained in:
parent
8445f2e55d
commit
f8532715c0
|
@ -75,6 +75,12 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
|
||||||
/* Tor Service interaction */
|
/* Tor Service interaction */
|
||||||
/* The primary interface we will be calling on the service. */
|
/* The primary interface we will be calling on the service. */
|
||||||
ITorService mService = null;
|
ITorService mService = null;
|
||||||
|
|
||||||
|
//should move this up with all the other class variables
|
||||||
|
private boolean mIsBound = false;
|
||||||
|
private Intent mTorService = null;
|
||||||
|
|
||||||
|
|
||||||
private boolean autoStartFromIntent = false;
|
private boolean autoStartFromIntent = false;
|
||||||
|
|
||||||
SharedPreferences mPrefs;
|
SharedPreferences mPrefs;
|
||||||
|
@ -89,6 +95,10 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
|
||||||
setLocale();
|
setLocale();
|
||||||
|
|
||||||
doLayout();
|
doLayout();
|
||||||
|
|
||||||
|
mTorService = new Intent(this, TorService.class);
|
||||||
|
getApplication().getApplicationContext().startService(mTorService);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doLayout ()
|
private void doLayout ()
|
||||||
|
@ -800,7 +810,8 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
|
||||||
if (torStatus != newTorStatus)
|
if (torStatus != newTorStatus)
|
||||||
{
|
{
|
||||||
imgStatus.setImageResource(R.drawable.toron);
|
imgStatus.setImageResource(R.drawable.toron);
|
||||||
mViewMain.setBackgroundResource(R.drawable.onionrootonly);
|
// mViewMain.setBackgroundResource(R.drawable.onionrootonly);
|
||||||
|
|
||||||
String lblMsg = getString(R.string.status_activated);
|
String lblMsg = getString(R.string.status_activated);
|
||||||
lblStatus.setText(lblMsg);
|
lblStatus.setText(lblMsg);
|
||||||
|
|
||||||
|
@ -842,7 +853,7 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
|
||||||
if (torStatus != newTorStatus)
|
if (torStatus != newTorStatus)
|
||||||
{
|
{
|
||||||
imgStatus.setImageResource(R.drawable.torstarting);
|
imgStatus.setImageResource(R.drawable.torstarting);
|
||||||
mViewMain.setBackgroundResource(R.drawable.onionrootonlygold);
|
// mViewMain.setBackgroundResource(R.drawable.onionrootonlygold);
|
||||||
|
|
||||||
if (mItemOnOff != null)
|
if (mItemOnOff != null)
|
||||||
mItemOnOff.setTitle(R.string.menu_stop);
|
mItemOnOff.setTitle(R.string.menu_stop);
|
||||||
|
@ -858,7 +869,7 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
|
||||||
}
|
}
|
||||||
else if (torStatus != newTorStatus)
|
else if (torStatus != newTorStatus)
|
||||||
{
|
{
|
||||||
mViewMain.setBackgroundResource(R.drawable.onionrootonlygrey);
|
// mViewMain.setBackgroundResource(R.drawable.onionrootonlygrey);
|
||||||
imgStatus.setImageResource(R.drawable.toroff);
|
imgStatus.setImageResource(R.drawable.toroff);
|
||||||
lblStatus.setText(getString(R.string.status_disabled) + "\n" + getString(R.string.press_to_start));
|
lblStatus.setText(getString(R.string.status_disabled) + "\n" + getString(R.string.press_to_start));
|
||||||
|
|
||||||
|
@ -1130,21 +1141,14 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//should move this up with all the other class variables
|
|
||||||
boolean mIsBound = false;
|
|
||||||
|
|
||||||
//this is where we bind!
|
//this is where we bind!
|
||||||
private void bindService ()
|
private void bindService ()
|
||||||
{
|
{
|
||||||
|
|
||||||
Intent iTorService = new Intent(this, TorService.class);
|
|
||||||
|
|
||||||
getApplication().getApplicationContext().startService(iTorService);
|
|
||||||
|
|
||||||
//since its auto create, we prob don't ever need to call startService
|
//since its auto create, we prob don't ever need to call startService
|
||||||
//also we should again be consistent with using either iTorService.class.getName()
|
//also we should again be consistent with using either iTorService.class.getName()
|
||||||
//or the variable constant
|
//or the variable constant
|
||||||
bindService(iTorService,
|
bindService(mTorService,
|
||||||
mConnection, Context.BIND_AUTO_CREATE);
|
mConnection, Context.BIND_AUTO_CREATE);
|
||||||
|
|
||||||
mIsBound = true;
|
mIsBound = true;
|
||||||
|
|
Loading…
Reference in New Issue