Compare commits

..

2 Commits

3 changed files with 226 additions and 198 deletions

View File

@@ -66,6 +66,7 @@ using Exception = System.Exception;
using String = System.String; using String = System.String;
using Toolbar = AndroidX.AppCompat.Widget.Toolbar; using Toolbar = AndroidX.AppCompat.Widget.Toolbar;
using AndroidX.Core.Content; using AndroidX.Core.Content;
using Google.Android.Material.Snackbar;
namespace keepass2android namespace keepass2android
{ {
@@ -131,7 +132,6 @@ namespace keepass2android
ISharedPreferences _prefs; ISharedPreferences _prefs;
private bool _starting; private bool _starting;
private bool _resumeCompleted;
private OtpInfo _otpInfo; private OtpInfo _otpInfo;
private IOConnectionInfo _otpAuxIoc; private IOConnectionInfo _otpAuxIoc;
private ChallengeInfo _chalInfo; private ChallengeInfo _chalInfo;
@@ -801,6 +801,8 @@ namespace keepass2android
_password = i.GetStringExtra(KeyPassword) ?? ""; _password = i.GetStringExtra(KeyPassword) ?? "";
if (!KeyProviderTypes.Any()) if (!KeyProviderTypes.Any())
{ {
SetKeyProviderFromString(LoadKeyProviderStringForIoc(_ioConnection.Path)); SetKeyProviderFromString(LoadKeyProviderStringForIoc(_ioConnection.Path));
} }
@@ -1570,8 +1572,6 @@ namespace keepass2android
} }
private bool hasRequestedKeyboardActivation = false; private bool hasRequestedKeyboardActivation = false;
protected override void OnStart() protected override void OnStart()
{ {
base.OnStart(); base.OnStart();
@@ -1691,20 +1691,15 @@ namespace keepass2android
//assume the key should be used as static password //assume the key should be used as static password
FindViewById<EditText>(Resource.Id.password_edit).Text += otp; FindViewById<EditText>(Resource.Id.password_edit).Text += otp;
} }
} }
else 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(); ResetState();
GetIocFromLaunchIntent(intent); GetIocFromLaunchIntent(intent);
InitializeAfterSetIoc(); InitializeAfterSetIoc();
OnStart(); OnStart();
}
} }
} }
@@ -1823,10 +1818,47 @@ namespace keepass2android
FindViewById(Resource.Id.otpInitView).Visibility = FindViewById(Resource.Id.otpInitView).Visibility =
_challengeSecret == null ? ViewStates.Visible : ViewStates.Gone; _challengeSecret == null ? ViewStates.Visible : ViewStates.Gone;
} }
/*
Snackbar snackbar = Snackbar
.Make(FindViewById(Resource.Id.main_content),
"snack snack snack snack snack snack snack snack snack snack snack snack snack snack snacksnack snack snacksnack snack snacksnack snack snack snack snack snack snack snack snack snack snack snack snack snack snack snacksnack snack snacksnack snack snacksnack snack snack snack snack snacksnack snack snack ",
Snackbar.LengthLong);
snackbar.SetTextMaxLines(5);
snackbar.SetBackgroundTint(GetColor(Resource.Color.md_theme_secondaryContainer));
snackbar.SetTextColor(GetColor(Resource.Color.md_theme_onSecondaryContainer));
snackbar.SetAction("dismiss",
view => snackbar.SetBackgroundTint(GetColor(Resource.Color.md_theme_surfaceContainer)));
snackbar.Show();
new Handler().PostDelayed(() =>
{
Snackbar snackbar2 = Snackbar
.Make(FindViewById(Resource.Id.main_content), "snack snack snack ",
Snackbar.LengthLong);
snackbar2.SetTextMaxLines(5);
snackbar2.SetBackgroundTint(GetColor(Resource.Color.md_theme_errorContainer));
snackbar2.SetTextColor(GetColor(Resource.Color.md_theme_onErrorContainer));
snackbar2.Show();
}, 1500);
new Handler().PostDelayed(() =>
{
Snackbar snackbar2 = Snackbar
.Make(FindViewById(Resource.Id.main_content), "snack snack warn ",
Snackbar.LengthLong);
snackbar2.SetTextMaxLines(5);
snackbar2.SetBackgroundTint(GetColor(Resource.Color.md_theme_inverseSurface));
snackbar2.SetTextColor(GetColor(Resource.Color.md_theme_inverseOnSurface));
snackbar2.Show();
}, 2500);*/
//use !IsFinishing to make sure we're not starting another activity when we're already finishing (e.g. due to TaskComplete in OnActivityResult) //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!) //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)
{ {
@@ -1873,10 +1905,10 @@ namespace keepass2android
bool showKeyboard = true; bool showKeyboard = true;
EditText pwd = (EditText)FindViewById(Resource.Id.password_edit); EditText pwd = (EditText) FindViewById(Resource.Id.password_edit);
pwd.PostDelayed(() => pwd.PostDelayed(() =>
{ {
InputMethodManager keyboard = (InputMethodManager)GetSystemService(InputMethodService); InputMethodManager keyboard = (InputMethodManager) GetSystemService(InputMethodService);
if (showKeyboard) if (showKeyboard)
{ {
pwd.RequestFocus(); pwd.RequestFocus();
@@ -1886,8 +1918,6 @@ namespace keepass2android
keyboard.HideSoftInputFromWindow(pwd.WindowToken, HideSoftInputFlags.ImplicitOnly); keyboard.HideSoftInputFromWindow(pwd.WindowToken, HideSoftInputFlags.ImplicitOnly);
}, 50); }, 50);
} }
_resumeCompleted = true;
} }
private void TryGetOtpFromClipboard() private void TryGetOtpFromClipboard()

View File

@@ -803,15 +803,13 @@ namespace keepass2android
var hasUnsecureDisplay = HasUnsecureDisplay(context); var hasUnsecureDisplay = HasUnsecureDisplay(context);
if (hasUnsecureDisplay) if (hasUnsecureDisplay)
{ {
Kp2aLog.Log("Display is not secure");
var intent = new Intent(context, typeof(NoSecureDisplayActivity)); var intent = new Intent(context, typeof(NoSecureDisplayActivity));
intent.AddFlags(ActivityFlags.SingleTop | ActivityFlags.ClearTop); intent.AddFlags(ActivityFlags.SingleTop | ActivityFlags.ClearTop);
context.StartActivityForResult(intent, 9999); context.StartActivityForResult(intent, 9999);
} }
Kp2aLog.Log("Setting FLAG_SECURE.");
context.Window.SetFlags(WindowManagerFlags.Secure, WindowManagerFlags.Secure); context.Window.SetFlags(WindowManagerFlags.Secure, WindowManagerFlags.Secure);
} }
else Kp2aLog.Log("Secure display disabled by user preference.");
} }
public static bool SecureDisplayConfigured(Activity context) public static bool SecureDisplayConfigured(Activity context)

View File

@@ -742,7 +742,7 @@
<PackageReference Include="Xamarin.AndroidX.AppCompat" Version="1.7.0.5" /> <PackageReference Include="Xamarin.AndroidX.AppCompat" Version="1.7.0.5" />
<PackageReference Include="Xamarin.AndroidX.AppCompat.AppCompatResources" Version="1.7.0.5" /> <PackageReference Include="Xamarin.AndroidX.AppCompat.AppCompatResources" Version="1.7.0.5" />
<PackageReference Include="Xamarin.AndroidX.AutoFill" Version="1.1.0.30" /> <PackageReference Include="Xamarin.AndroidX.AutoFill" Version="1.1.0.30" />
<PackageReference Include="Xamarin.AndroidX.Biometric" Version="1.1.0.27" /> <PackageReference Include="Xamarin.AndroidX.Biometric" Version="1.1.0.6" />
<PackageReference Include="Xamarin.AndroidX.CoordinatorLayout" Version="1.3.0" /> <PackageReference Include="Xamarin.AndroidX.CoordinatorLayout" Version="1.3.0" />
<PackageReference Include="Xamarin.AndroidX.CursorAdapter" Version="1.0.0.31" /> <PackageReference Include="Xamarin.AndroidX.CursorAdapter" Version="1.0.0.31" />
<PackageReference Include="Xamarin.AndroidX.Lifecycle.Common" Version="2.8.7.2" /> <PackageReference Include="Xamarin.AndroidX.Lifecycle.Common" Version="2.8.7.2" />