Kill wizard activities on Exit

Orbot.java's doExit() returns a
RESULT_CLOSE_ALL to the wizard activities.
The onActivityResult() is overrided
in the wizard activities to kill all
the activities if the result is
RESULT_CLOSE_ALL
This commit is contained in:
Sathyanarayanan Gunasekaran 2011-11-04 01:44:50 +05:30
parent 821b911db3
commit 4574c95b55
6 changed files with 53 additions and 5 deletions

View File

@ -228,7 +228,7 @@ public class Orbot extends Activity implements OnLongClickListener, TorConstants
private void doExit () private void doExit ()
{ {
try { try {
//one of the confusing things about all of this code is the multiple //one of the confusing things about all of this code is the multiple
//places where things like "stopTor" are called, both in the Activity and the Service //places where things like "stopTor" are called, both in the Activity and the Service
//not something to tackle in your first iteration, but i thin we can talk about fixing //not something to tackle in your first iteration, but i thin we can talk about fixing
@ -247,6 +247,8 @@ public class Orbot extends Activity implements OnLongClickListener, TorConstants
Log.w(TAG, e); Log.w(TAG, e);
} }
//Kill all the wizard activities
setResult(RESULT_CLOSE_ALL);
finish(); finish();
} }

View File

@ -41,7 +41,7 @@ public interface TorConstants {
public final static String PREF_TRANSPARENT_ALL = "pref_transparent_all"; public final static String PREF_TRANSPARENT_ALL = "pref_transparent_all";
public final static String PREF_HAS_ROOT = "has_root"; public final static String PREF_HAS_ROOT = "has_root";
public final static int RESULT_CLOSE_ALL = 0;
} }

View File

@ -61,6 +61,18 @@ public class ConfigureTransProxy extends Activity implements TorConstants {
} }
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch(resultCode)
{
case RESULT_CLOSE_ALL:
setResult(RESULT_CLOSE_ALL);
finish();
}
super.onActivityResult(requestCode, resultCode, data);
}
private void setupUI () private void setupUI ()
{ {
@ -202,7 +214,7 @@ public class ConfigureTransProxy extends Activity implements TorConstants {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
context.startActivity(new Intent(context, Orbot.class)); startActivityForResult(new Intent(getBaseContext(), Orbot.class), 1);
} }
}; };

View File

@ -55,7 +55,18 @@ public class LotsaText extends Activity implements TorConstants{
} }
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch(resultCode)
{
case RESULT_CLOSE_ALL:
setResult(RESULT_CLOSE_ALL);
finish();
}
super.onActivityResult(requestCode, resultCode, data);
}
private void stepOne() { private void stepOne() {
@ -135,6 +146,6 @@ public class LotsaText extends Activity implements TorConstants{
}); });
} }
} }

View File

@ -55,6 +55,18 @@ public class Permissions extends Activity implements TorConstants {
} }
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch(resultCode)
{
case RESULT_CLOSE_ALL:
setResult(RESULT_CLOSE_ALL);
finish();
}
super.onActivityResult(requestCode, resultCode, data);
}
private void stepThree(){ private void stepThree(){
boolean isRootPossible = TorServiceUtils.isRootPossible(); boolean isRootPossible = TorServiceUtils.isRootPossible();

View File

@ -49,6 +49,17 @@ public class TipsAndTricks extends Activity implements TorConstants {
} }
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch(resultCode)
{
case RESULT_CLOSE_ALL:
setResult(RESULT_CLOSE_ALL);
finish();
}
super.onActivityResult(requestCode, resultCode, data);
}
void stepFive(){ void stepFive(){
String title = getString(R.string.wizard_tips_title); String title = getString(R.string.wizard_tips_title);
@ -141,7 +152,7 @@ public class TipsAndTricks extends Activity implements TorConstants {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
startActivity(new Intent(getBaseContext(), Orbot.class)); startActivityForResult(new Intent(getBaseContext(), Orbot.class), 1);
} }
}); });