use one prefs instance

This commit is contained in:
Nathan Freitas 2014-06-13 12:59:02 -04:00
parent 2ce9ea92f1
commit c0f7d754dd
1 changed files with 5 additions and 11 deletions

View File

@ -86,6 +86,7 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
//should move this up with all the other class variables
private boolean mIsBound = false;
private SharedPreferences mPrefs = null;
private boolean autoStartFromIntent = false;
@ -93,8 +94,8 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TorServiceUtils.getSharedPrefs(getApplicationContext()).registerOnSharedPreferenceChangeListener(this);
mPrefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
mPrefs.registerOnSharedPreferenceChangeListener(this);
setLocale();
@ -490,7 +491,6 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
private void enableHiddenServicePort (int hsPort)
{
SharedPreferences mPrefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
Editor pEdit = mPrefs.edit();
@ -609,7 +609,6 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
newBridgeValue = URLDecoder.decode(newBridgeValue); //decode the value here
showAlert("Bridges Updated","Restart Orbot to use this bridge: " + newBridgeValue,false);
SharedPreferences mPrefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
String bridges = mPrefs.getString(TorConstants.PREF_BRIDGES_LIST, null);
@ -635,8 +634,6 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
else
{
SharedPreferences mPrefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
showWizard = mPrefs.getBoolean("show_wizard",showWizard);
if (showWizard)
@ -683,7 +680,6 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
*/
private void openBrowser(final String browserLaunchUrl)
{
SharedPreferences mPrefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
boolean isOrwebInstalled = appInstalledOrNot("info.guardianproject.browser");
boolean isTransProxy = mPrefs.getBoolean("pref_transparent", false);
@ -904,7 +900,6 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
appendLogTextAndScroll(mTorServiceMsg);
}
SharedPreferences mPrefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
boolean showFirstTime = mPrefs.getBoolean("connect_first_time",true);
if (showFirstTime)
@ -1282,7 +1277,6 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
Configuration config = getResources().getConfiguration();
SharedPreferences mPrefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
String lang = mPrefs.getString(PREF_DEFAULT_LOCALE, "");
if (! "".equals(lang) && ! config.locale.getLanguage().equals(lang))