do not reset activity state in OnNewIntent if the activity hasn't even been initialized. closes #2869, closes #2888

This commit is contained in:
Philipp Crocoll
2025-06-17 14:04:15 +02:00
parent e1f26fb045
commit e2babde1fa

View File

@@ -131,6 +131,7 @@ namespace keepass2android
ISharedPreferences _prefs;
private bool _starting;
private bool _resumeCompleted;
private OtpInfo _otpInfo;
private IOConnectionInfo _otpAuxIoc;
private ChallengeInfo _chalInfo;
@@ -1569,6 +1570,8 @@ namespace keepass2android
}
private bool hasRequestedKeyboardActivation = false;
protected override void OnStart()
{
base.OnStart();
@@ -1688,15 +1691,20 @@ namespace keepass2android
//assume the key should be used as static password
FindViewById<EditText>(Resource.Id.password_edit).Text += otp;
}
}
else
{
// if the activity is launched twice and the first initialization hasn't even finished, we cannot
// reset the state and re-initialize the activity.
// This can happen with autofill in some cases (#2869)
if (_resumeCompleted)
{
ResetState();
GetIocFromLaunchIntent(intent);
InitializeAfterSetIoc();
OnStart();
}
}
}
@@ -1818,7 +1826,7 @@ namespace keepass2android
//use !IsFinishing to make sure we're not starting another activity when we're already finishing (e.g. due to TaskComplete in OnActivityResult)
//use !performingLoad to make sure we're not already loading the database (after ActivityResult from File-Prepare-Activity; this would cause _loadDbFileTask to exist when we reload later!)
if ( !IsFinishing && !_performingLoad)
if (!IsFinishing && !_performingLoad)
{
@@ -1865,10 +1873,10 @@ namespace keepass2android
bool showKeyboard = true;
EditText pwd = (EditText) FindViewById(Resource.Id.password_edit);
EditText pwd = (EditText)FindViewById(Resource.Id.password_edit);
pwd.PostDelayed(() =>
{
InputMethodManager keyboard = (InputMethodManager) GetSystemService(InputMethodService);
InputMethodManager keyboard = (InputMethodManager)GetSystemService(InputMethodService);
if (showKeyboard)
{
pwd.RequestFocus();
@@ -1878,6 +1886,8 @@ namespace keepass2android
keyboard.HideSoftInputFromWindow(pwd.WindowToken, HideSoftInputFlags.ImplicitOnly);
}, 50);
}
_resumeCompleted = true;
}
private void TryGetOtpFromClipboard()