mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-18 05:39:53 +01:00
Start SetupActivity in same task, finish other activities.
This commit is contained in:
@@ -62,11 +62,10 @@ public abstract class BriarActivity extends BaseActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onActivityResult(int request, int result, Intent data) {
|
protected void onActivityResult(int request, int result, Intent data) {
|
||||||
super.onActivityResult(request, result, data);
|
super.onActivityResult(request, result, data);
|
||||||
if (request == REQUEST_PASSWORD && result == RESULT_OK) {
|
if (request == REQUEST_PASSWORD) {
|
||||||
// PasswordActivity finishes when password was entered correctly.
|
// The result can be RESULT_CANCELED if there's no account
|
||||||
// When back button is pressed there, it will bring itself back,
|
if (result == RESULT_OK) briarController.startAndBindService();
|
||||||
// so that we never arrive here with a result that is not OK.
|
else finish();
|
||||||
briarController.startAndBindService();
|
|
||||||
} else if (request == REQUEST_UNLOCK && result != RESULT_OK) {
|
} else if (request == REQUEST_UNLOCK && result != RESULT_OK) {
|
||||||
// We arrive here, if the user presses 'back'
|
// We arrive here, if the user presses 'back'
|
||||||
// in the Keyguard unlock screen, because UnlockActivity finishes.
|
// in the Keyguard unlock screen, because UnlockActivity finishes.
|
||||||
@@ -81,13 +80,16 @@ public abstract class BriarActivity extends BaseActivity {
|
|||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
if (!briarController.accountSignedIn()) {
|
if (!briarController.accountSignedIn() && !isFinishing()) {
|
||||||
|
// Also check that the activity isn't finishing already.
|
||||||
|
// This is possible if we finished in onActivityResult().
|
||||||
|
// Launching another PasswordActivity would cause a loop.
|
||||||
Intent i = new Intent(this, PasswordActivity.class);
|
Intent i = new Intent(this, PasswordActivity.class);
|
||||||
startActivityForResult(i, REQUEST_PASSWORD);
|
startActivityForResult(i, REQUEST_PASSWORD);
|
||||||
} else if (lockManager.isLocked() && !isFinishing()) {
|
} else if (lockManager.isLocked() && !isFinishing()) {
|
||||||
// Also check that the activity isn't finishing already.
|
// Also check that the activity isn't finishing already.
|
||||||
// This is possible if finishing in onActivityResult().
|
// This is possible if we finished in onActivityResult().
|
||||||
// Failure to do this check would cause an UnlockActivity loop.
|
// Lauching another UnlockActivity would cause a loop.
|
||||||
Intent i = new Intent(this, UnlockActivity.class);
|
Intent i = new Intent(this, UnlockActivity.class);
|
||||||
startActivityForResult(i, REQUEST_UNLOCK);
|
startActivityForResult(i, REQUEST_UNLOCK);
|
||||||
} else if (SDK_INT >= 23) {
|
} else if (SDK_INT >= 23) {
|
||||||
|
|||||||
@@ -23,8 +23,6 @@ import org.briarproject.briar.api.android.AndroidNotificationManager;
|
|||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TASK;
|
|
||||||
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
|
|
||||||
import static android.view.View.INVISIBLE;
|
import static android.view.View.INVISIBLE;
|
||||||
import static android.view.View.VISIBLE;
|
import static android.view.View.VISIBLE;
|
||||||
|
|
||||||
@@ -54,8 +52,8 @@ public class PasswordActivity extends BaseActivity {
|
|||||||
overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
|
overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
|
||||||
|
|
||||||
if (!accountManager.accountExists()) {
|
if (!accountManager.accountExists()) {
|
||||||
// TODO: Finish instead of deleting account?
|
setResult(RESULT_CANCELED);
|
||||||
deleteAccount();
|
finish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,10 +112,9 @@ public class PasswordActivity extends BaseActivity {
|
|||||||
|
|
||||||
private void deleteAccount() {
|
private void deleteAccount() {
|
||||||
accountManager.deleteAccount();
|
accountManager.deleteAccount();
|
||||||
|
startActivity(new Intent(this, SetupActivity.class));
|
||||||
setResult(RESULT_CANCELED);
|
setResult(RESULT_CANCELED);
|
||||||
Intent i = new Intent(this, SetupActivity.class);
|
finish();
|
||||||
i.setFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TASK);
|
|
||||||
startActivity(i);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onSignInClick(View v) {
|
public void onSignInClick(View v) {
|
||||||
|
|||||||
Reference in New Issue
Block a user