Merge branch '7-password-activity' into 'master'

Show home screen if user backs out of password activity

This borrows a technique from @grote's crash reporter patch to fix #7. If the user presses the back button in PasswordActivity, the home screen is shown. Previously, pressing the back button removed PasswordActivity from the back stack, causing the next activity in the back stack to spawn another PasswordActivity.


See merge request !41
This commit is contained in:
akwizgran
2015-12-28 18:09:00 +00:00

View File

@@ -2,6 +2,7 @@ package org.briarproject.android;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
import android.view.KeyEvent;
@@ -24,6 +25,8 @@ import java.util.concurrent.Executor;
import javax.inject.Inject;
import static android.content.Intent.ACTION_MAIN;
import static android.content.Intent.CATEGORY_HOME;
import static android.view.View.INVISIBLE;
import static android.view.View.VISIBLE;
import static android.view.inputmethod.EditorInfo.IME_ACTION_DONE;
@@ -69,6 +72,14 @@ public class PasswordActivity extends BaseActivity {
});
}
@Override
public void onBackPressed() {
// Show the home screen rather than another password prompt
Intent intent = new Intent(ACTION_MAIN);
intent.addCategory(CATEGORY_HOME);
startActivity(intent);
}
@Override
protected void clearDbPrefs() {
super.clearDbPrefs();