clean up bind/unbind and handleIntent wizard logic

This commit is contained in:
Nathan Freitas 2014-06-11 22:04:15 -04:00
parent 917ec8d7a0
commit 44648f16c3
1 changed files with 14 additions and 35 deletions

View File

@ -113,18 +113,9 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
torService = new Intent(this, TorService.class); torService = new Intent(this, TorService.class);
startService(torService); startService(torService);
/*
if (Build.VERSION.SDK_INT > 14)
{
bindService(torService, bindService(torService,
mConnection, Context.BIND_AUTO_CREATE|Context.BIND_IMPORTANT|Context.BIND_ABOVE_CLIENT); mConnection, Context.BIND_AUTO_CREATE);
}
else
{
*/
//}
} }
@ -395,7 +386,8 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
} }
else if (item.getItemId() == R.id.menu_wizard) else if (item.getItemId() == R.id.menu_wizard)
{ {
startWizard(); startActivity(new Intent(this, ChooseLocaleWizardActivity.class));
} }
else if (item.getItemId() == R.id.menu_verify) else if (item.getItemId() == R.id.menu_verify)
{ {
@ -465,7 +457,6 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
if (aDialog != null) if (aDialog != null)
aDialog.dismiss(); aDialog.dismiss();
unbindService(mConnection);
} }
private void doTorCheck () private void doTorCheck ()
@ -540,7 +531,7 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
} }
private void handleIntents () private synchronized void handleIntents ()
{ {
if (getIntent() == null) if (getIntent() == null)
return; return;
@ -646,15 +637,17 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
SharedPreferences mPrefs = TorServiceUtils.getSharedPrefs(getApplicationContext()); SharedPreferences mPrefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
boolean showWizard = mPrefs.getBoolean("show_wizard",true); showWizard = mPrefs.getBoolean("show_wizard",showWizard);
if (showWizard) if (showWizard)
{ {
Editor pEdit = mPrefs.edit(); Editor pEdit = mPrefs.edit();
pEdit.putBoolean("show_wizard",false); pEdit.putBoolean("show_wizard",false);
pEdit.commit(); pEdit.commit();
showWizard = false;
startActivity(new Intent(this, ChooseLocaleWizardActivity.class));
startWizard();
} }
} }
@ -664,7 +657,7 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
} }
private boolean showWizard = true;
@Override @Override
@ -771,19 +764,6 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
} }
} }
/*
* Show the help view - a popup dialog
*/
private void startWizard ()
{
SharedPreferences mPrefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
Editor pEdit = mPrefs.edit();
pEdit.putBoolean("wizardscreen1",true);
pEdit.commit();
startActivity(new Intent(getApplicationContext(), ChooseLocaleWizardActivity.class));
}
/* /*
* Load the basic settings application to display torrc * Load the basic settings application to display torrc
*/ */
@ -799,9 +779,6 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
bindService(torService,
mConnection, 0);
if (mService != null) if (mService != null)
{ {
try { try {
@ -810,6 +787,8 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
mService.processSettings(); mService.processSettings();
setLocale(); setLocale();
handleIntents();
} catch (RemoteException e) { } catch (RemoteException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();