mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-04-23 23:39:14 +00:00
Guard against starting multiple instances of IntroActivity or AuthActivity
Apparently onResume of MainActivity is sometimes called even if it's not the top level activity, causing IntroActivity or AuthActivity to be launched twice. This patch (uglily) prevents that from happening.
This commit is contained in:
parent
7bb8d28b3b
commit
189bd0d749
1 changed files with 28 additions and 7 deletions
|
@ -20,6 +20,7 @@ import android.view.View;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.view.ActionMode;
|
import androidx.appcompat.view.ActionMode;
|
||||||
import androidx.appcompat.widget.SearchView;
|
import androidx.appcompat.widget.SearchView;
|
||||||
|
|
||||||
|
@ -76,6 +77,9 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
||||||
private String _selectedGroup;
|
private String _selectedGroup;
|
||||||
private boolean _searchSubmitted;
|
private boolean _searchSubmitted;
|
||||||
|
|
||||||
|
private boolean _isAuthenticating;
|
||||||
|
private boolean _isDoingIntro;
|
||||||
|
|
||||||
private List<VaultEntry> _selectedEntries;
|
private List<VaultEntry> _selectedEntries;
|
||||||
private ActionMode _actionMode;
|
private ActionMode _actionMode;
|
||||||
|
|
||||||
|
@ -92,13 +96,16 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_main);
|
||||||
|
|
||||||
_app = (AegisApplication) getApplication();
|
_app = (AegisApplication) getApplication();
|
||||||
_vault = _app.getVaultManager();
|
_vault = _app.getVaultManager();
|
||||||
_loaded = false;
|
_loaded = false;
|
||||||
|
|
||||||
// set up the main view
|
if (savedInstanceState != null) {
|
||||||
setContentView(R.layout.activity_main);
|
_isAuthenticating = savedInstanceState.getBoolean("isAuthenticating");
|
||||||
|
_isDoingIntro = savedInstanceState.getBoolean("isDoingIntro");
|
||||||
|
}
|
||||||
|
|
||||||
// set up the entry view
|
// set up the entry view
|
||||||
_entryListView = (EntryListView) getSupportFragmentManager().findFragmentById(R.id.key_profiles);
|
_entryListView = (EntryListView) getSupportFragmentManager().findFragmentById(R.id.key_profiles);
|
||||||
|
@ -137,6 +144,13 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
||||||
_selectedEntries = new ArrayList<>();
|
_selectedEntries = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
||||||
|
super.onSaveInstanceState(outState);
|
||||||
|
outState.putBoolean("isAuthenticating", _isAuthenticating);
|
||||||
|
outState.putBoolean("isDoingIntro", _isDoingIntro);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
_entryListView.setListener(null);
|
_entryListView.setListener(null);
|
||||||
|
@ -162,6 +176,9 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
|
_isAuthenticating = false;
|
||||||
|
_isDoingIntro = false;
|
||||||
|
|
||||||
if (resultCode != RESULT_OK) {
|
if (resultCode != RESULT_OK) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -449,12 +466,13 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
||||||
|
|
||||||
if (_vault == null) {
|
if (_vault == null) {
|
||||||
// start the intro if the vault file doesn't exist
|
// start the intro if the vault file doesn't exist
|
||||||
if (!VaultManager.fileExists(this)) {
|
if (!_isDoingIntro && !VaultManager.fileExists(this)) {
|
||||||
if (getPreferences().isIntroDone()) {
|
if (getPreferences().isIntroDone()) {
|
||||||
Toast.makeText(this, getString(R.string.vault_not_found), Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, getString(R.string.vault_not_found), Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
Intent intro = new Intent(this, IntroActivity.class);
|
Intent intro = new Intent(this, IntroActivity.class);
|
||||||
startActivityForResult(intro, CODE_DO_INTRO);
|
startActivityForResult(intro, CODE_DO_INTRO);
|
||||||
|
_isDoingIntro = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -635,10 +653,13 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startAuthActivity(boolean inhibitBioPrompt) {
|
private void startAuthActivity(boolean inhibitBioPrompt) {
|
||||||
Intent intent = new Intent(this, AuthActivity.class);
|
if (!_isAuthenticating) {
|
||||||
intent.putExtra("cancelAction", CancelAction.KILL);
|
Intent intent = new Intent(this, AuthActivity.class);
|
||||||
intent.putExtra("inhibitBioPrompt", inhibitBioPrompt);
|
intent.putExtra("cancelAction", CancelAction.KILL);
|
||||||
startActivityForResult(intent, CODE_DECRYPT);
|
intent.putExtra("inhibitBioPrompt", inhibitBioPrompt);
|
||||||
|
startActivityForResult(intent, CODE_DECRYPT);
|
||||||
|
_isAuthenticating = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateLockIcon() {
|
private void updateLockIcon() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue