commit d5293340d56799b79d0a8f3389851d54b31f92de
Author: Nathan Freitas <nathan(a)freitas.net>
Date: Fri Apr 25 12:42:31 2014 -0400
clean up wizard context use
---
.../android/wizard/ChooseLocaleWizardActivity.java | 19 ++++---------------
.../android/wizard/ConfigureTransProxy.java | 9 +++++----
src/org/torproject/android/wizard/LotsaText.java | 9 +++++----
src/org/torproject/android/wizard/Permissions.java | 15 ++++++++-------
.../torproject/android/wizard/TipsAndTricks.java | 6 +++---
5 files changed, 25 insertions(+), 33 deletions(-)
diff --git a/src/org/torproject/android/wizard/ChooseLocaleWizardActivity.java b/src/org/torproject/android/wizard/ChooseLocaleWizardActivity.java
index 7d7f7cd..6385227 100644
--- a/src/org/torproject/android/wizard/ChooseLocaleWizardActivity.java
+++ b/src/org/torproject/android/wizard/ChooseLocaleWizardActivity.java
@@ -4,6 +4,7 @@ import java.util.Locale;
import org.torproject.android.R;
import org.torproject.android.TorConstants;
+import org.torproject.android.service.TorServiceUtils;
import android.app.Activity;
import android.content.Context;
@@ -22,14 +23,12 @@ import android.widget.ListView;
public class ChooseLocaleWizardActivity extends Activity implements TorConstants {
- private Context context;
private int flag = 0;
private ListView listLocales;
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
- context = this;
}
@@ -47,21 +46,11 @@ public class ChooseLocaleWizardActivity extends Activity implements TorConstants
protected void onResume() {
super.onResume();
- setupUI();
-
}
- private void setupUI ()
- {
-// SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
-
-
- }
-
-
private void stepSix(){
listLocales = (ListView)findViewById(R.id.wizard_locale_list);
@@ -84,7 +73,7 @@ public class ChooseLocaleWizardActivity extends Activity implements TorConstants
int arg2, long arg3) {
setLocalePref(arg2);
- startActivityForResult(new Intent(getBaseContext(), LotsaText.class), 1);
+ startActivityForResult(new Intent(ChooseLocaleWizardActivity.this, LotsaText.class), 1);
}
});
@@ -94,7 +83,7 @@ public class ChooseLocaleWizardActivity extends Activity implements TorConstants
public void onClick(View v) {
- startActivityForResult(new Intent(getBaseContext(), LotsaText.class), 1);
+ startActivityForResult(new Intent(ChooseLocaleWizardActivity.this, LotsaText.class), 1);
}
});
@@ -106,7 +95,7 @@ public class ChooseLocaleWizardActivity extends Activity implements TorConstants
private void setLocalePref(int selId)
{
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
+ SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
Configuration config = getResources().getConfiguration();
diff --git a/src/org/torproject/android/wizard/ConfigureTransProxy.java b/src/org/torproject/android/wizard/ConfigureTransProxy.java
index 856fd0f..abbaee6 100644
--- a/src/org/torproject/android/wizard/ConfigureTransProxy.java
+++ b/src/org/torproject/android/wizard/ConfigureTransProxy.java
@@ -7,6 +7,7 @@ import org.torproject.android.R.drawable;
import org.torproject.android.R.id;
import org.torproject.android.R.layout;
import org.torproject.android.R.string;
+import org.torproject.android.service.TorServiceUtils;
import org.torproject.android.settings.AppManager;
import android.app.Activity;
@@ -76,7 +77,7 @@ public class ConfigureTransProxy extends Activity implements TorConstants {
private void setupUI ()
{
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
+ SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
boolean transEnabled = prefs.getBoolean(PREF_TRANSPARENT, false);
@@ -119,7 +120,7 @@ public class ConfigureTransProxy extends Activity implements TorConstants {
public void onClick(View v) {
- startActivityForResult(new Intent(getBaseContext(), Permissions.class), 1);
+ startActivityForResult(new Intent(ConfigureTransProxy.this, Permissions.class), 1);
}
});
@@ -127,7 +128,7 @@ public class ConfigureTransProxy extends Activity implements TorConstants {
public void onClick(View v) {
- startActivityForResult(new Intent(getBaseContext(), TipsAndTricks.class), 1);
+ startActivityForResult(new Intent(ConfigureTransProxy.this, TipsAndTricks.class), 1);
}
});
@@ -162,7 +163,7 @@ public class ConfigureTransProxy extends Activity implements TorConstants {
RadioButton rb1 = (RadioButton)findViewById(R.id.radio1);
RadioButton rb2 = (RadioButton)findViewById(R.id.radio2);
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
+ SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
Editor pEdit = prefs.edit();
pEdit.putBoolean(PREF_TRANSPARENT, rb0.isChecked());
diff --git a/src/org/torproject/android/wizard/LotsaText.java b/src/org/torproject/android/wizard/LotsaText.java
index b831cca..3568779 100644
--- a/src/org/torproject/android/wizard/LotsaText.java
+++ b/src/org/torproject/android/wizard/LotsaText.java
@@ -6,6 +6,7 @@ import org.torproject.android.R.drawable;
import org.torproject.android.R.id;
import org.torproject.android.R.layout;
import org.torproject.android.R.string;
+import org.torproject.android.service.TorServiceUtils;
import android.app.Activity;
import android.content.Context;
@@ -40,7 +41,7 @@ public class LotsaText extends Activity implements TorConstants{
super.onStart();
setContentView(R.layout.scrollingtext_buttons_view);
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
+ SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
boolean wizardScreen1 = prefs.getBoolean("wizardscreen1",true);
if(wizardScreen1)
@@ -72,7 +73,7 @@ public class LotsaText extends Activity implements TorConstants{
private void stepOne() {
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
+ SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
Editor pEdit = prefs.edit();
pEdit.putBoolean("wizardscreen1",true);
@@ -102,7 +103,7 @@ public class LotsaText extends Activity implements TorConstants{
private void stepTwo() {
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
+ SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
Editor pEdit = prefs.edit();
pEdit.putBoolean("wizardscreen1",false);
@@ -134,7 +135,7 @@ public class LotsaText extends Activity implements TorConstants{
btn2.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
- startActivityForResult(new Intent(getBaseContext(), Permissions.class), 1);
+ startActivityForResult(new Intent(LotsaText.this, Permissions.class), 1);
}
});
diff --git a/src/org/torproject/android/wizard/Permissions.java b/src/org/torproject/android/wizard/Permissions.java
index 0b876b6..37db185 100644
--- a/src/org/torproject/android/wizard/Permissions.java
+++ b/src/org/torproject/android/wizard/Permissions.java
@@ -4,6 +4,7 @@ import org.sufficientlysecure.rootcommands.RootCommands;
import org.torproject.android.R;
import org.torproject.android.TorConstants;
import org.torproject.android.service.TorService;
+import org.torproject.android.service.TorServiceUtils;
import android.app.Activity;
import android.content.Context;
@@ -92,7 +93,7 @@ public class Permissions extends Activity implements TorConstants {
//this is saying do not use root
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
+ SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
Editor pEdit = prefs.edit();
@@ -122,7 +123,7 @@ public class Permissions extends Activity implements TorConstants {
public void onClick(View v) {
//Check and Install iptables - TorTransProxy.testOwnerModule(this)
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
+ SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
boolean hasRoot = RootCommands.rootAccessGiven();
Editor pEdit = prefs.edit();
@@ -137,7 +138,7 @@ public class Permissions extends Activity implements TorConstants {
}
else
{
- startActivityForResult(new Intent(getBaseContext(), ConfigureTransProxy.class), 1);
+ startActivityForResult(new Intent(Permissions.this, ConfigureTransProxy.class), 1);
}
@@ -150,7 +151,7 @@ public class Permissions extends Activity implements TorConstants {
public void onClick(View v) {
- startActivityForResult(new Intent(getBaseContext(), LotsaText.class), 1);
+ startActivityForResult(new Intent(Permissions.this, LotsaText.class), 1);
}
});
@@ -159,7 +160,7 @@ public class Permissions extends Activity implements TorConstants {
public void onClick(View v) {
- startActivityForResult(new Intent(getBaseContext(), TipsAndTricks.class), 1);
+ startActivityForResult(new Intent(Permissions.this, TipsAndTricks.class), 1);
}
});
@@ -193,14 +194,14 @@ public class Permissions extends Activity implements TorConstants {
public void onClick(View v) {
- startActivityForResult(new Intent(getBaseContext(), LotsaText.class), 1);
+ startActivityForResult(new Intent(Permissions.this, LotsaText.class), 1);
}
});
btn2.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
- startActivityForResult(new Intent(getBaseContext(), TipsAndTricks.class), 1);
+ startActivityForResult(new Intent(Permissions.this, TipsAndTricks.class), 1);
}
});
}
diff --git a/src/org/torproject/android/wizard/TipsAndTricks.java b/src/org/torproject/android/wizard/TipsAndTricks.java
index 7b32ec3..5d0872c 100644
--- a/src/org/torproject/android/wizard/TipsAndTricks.java
+++ b/src/org/torproject/android/wizard/TipsAndTricks.java
@@ -149,7 +149,7 @@ public class TipsAndTricks extends Activity implements TorConstants {
public void onClick(View v) {
- startActivityForResult(new Intent(getBaseContext(), Permissions.class), 1);
+ startActivityForResult(new Intent(TipsAndTricks.this, Permissions.class), 1);
}
});
@@ -183,7 +183,7 @@ public class TipsAndTricks extends Activity implements TorConstants {
btn1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
- startActivityForResult(new Intent(getBaseContext(), Permissions.class), 1);
+ startActivityForResult(new Intent(TipsAndTricks.this, Permissions.class), 1);
}
});
@@ -191,7 +191,7 @@ public class TipsAndTricks extends Activity implements TorConstants {
btn2.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
- startActivityForResult(new Intent(getBaseContext(), Orbot.class), 1);
+ startActivityForResult(new Intent(TipsAndTricks.this, Orbot.class), 1);
}
});