Compare commits

..

1 Commits

11 changed files with 584 additions and 203 deletions

View File

@@ -66,6 +66,7 @@ using Exception = System.Exception;
using String = System.String;
using Toolbar = AndroidX.AppCompat.Widget.Toolbar;
using AndroidX.Core.Content;
using Google.Android.Material.Snackbar;
namespace keepass2android
{
@@ -131,8 +132,7 @@ namespace keepass2android
ISharedPreferences _prefs;
private bool _starting;
private bool _resumeCompleted;
private OtpInfo _otpInfo;
private OtpInfo _otpInfo;
private IOConnectionInfo _otpAuxIoc;
private ChallengeInfo _chalInfo;
private byte[] _challengeSecret;
@@ -801,6 +801,8 @@ namespace keepass2android
_password = i.GetStringExtra(KeyPassword) ?? "";
if (!KeyProviderTypes.Any())
{
SetKeyProviderFromString(LoadKeyProviderStringForIoc(_ioConnection.Path));
}
@@ -1253,7 +1255,7 @@ namespace keepass2android
case 6:
KeyProviderTypes.Add(KeyProviders.ChallengeXC);
break;
case 7:
case 7:
//don't set to "" to prevent losing the filename. (ItemSelected is also called during recreation!)
Kp2aLog.Log("key file length before: " + _keyFile?.Length);
_keyFile = (FindViewById(Resource.Id.label_keyfilename).Tag ?? "").ToString();
@@ -1570,9 +1572,7 @@ namespace keepass2android
}
private bool hasRequestedKeyboardActivation = false;
protected override void OnStart()
protected override void OnStart()
{
base.OnStart();
_starting = true;
@@ -1647,65 +1647,60 @@ namespace keepass2android
if (intent != null)
{
if (intent.HasExtra(Intents.OtpExtraKey))
{
string otp = intent.GetStringExtra(Intents.OtpExtraKey);
_keepPasswordInOnResume = true;
if (KeyProviderTypes.Contains(KeyProviders.Otp))
{
if (_otpInfo == null)
{
//Entering OTPs not yet initialized:
_pendingOtps.Add(otp);
UpdateKeyProviderUiState();
}
else
{
//Entering OTPs is initialized. Write OTP into first empty field:
bool foundEmptyField = false;
foreach (int otpId in _otpTextViewIds)
{
EditText otpEdit = FindViewById<EditText>(otpId);
if ((otpEdit.Visibility == ViewStates.Visible) && String.IsNullOrEmpty(otpEdit.Text))
{
otpEdit.Text = otp;
foundEmptyField = true;
break;
}
}
//did we find a field?
if (!foundEmptyField)
{
App.Kp2a.ShowMessage(this, GetString(Resource.String.otp_discarded_no_space), MessageSeverity.Error);
}
}
Spinner passwordModeSpinner = FindViewById<Spinner>(Resource.Id.password_mode_spinner);
if (passwordModeSpinner.SelectedItemPosition != (int)KeyProviders.Otp)
{
passwordModeSpinner.SetSelection((int)KeyProviders.Otp);
}
}
else
{
//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)
{
string otp = intent.GetStringExtra(Intents.OtpExtraKey);
_keepPasswordInOnResume = true;
if (KeyProviderTypes.Contains(KeyProviders.Otp))
{
ResetState();
GetIocFromLaunchIntent(intent);
InitializeAfterSetIoc();
OnStart();
if (_otpInfo == null)
{
//Entering OTPs not yet initialized:
_pendingOtps.Add(otp);
UpdateKeyProviderUiState();
}
else
{
//Entering OTPs is initialized. Write OTP into first empty field:
bool foundEmptyField = false;
foreach (int otpId in _otpTextViewIds)
{
EditText otpEdit = FindViewById<EditText>(otpId);
if ((otpEdit.Visibility == ViewStates.Visible) && String.IsNullOrEmpty(otpEdit.Text))
{
otpEdit.Text = otp;
foundEmptyField = true;
break;
}
}
//did we find a field?
if (!foundEmptyField)
{
App.Kp2a.ShowMessage(this, GetString(Resource.String.otp_discarded_no_space), MessageSeverity.Error);
}
}
Spinner passwordModeSpinner = FindViewById<Spinner>(Resource.Id.password_mode_spinner);
if (passwordModeSpinner.SelectedItemPosition != (int)KeyProviders.Otp)
{
passwordModeSpinner.SetSelection((int)KeyProviders.Otp);
}
}
}
else
{
//assume the key should be used as static password
FindViewById<EditText>(Resource.Id.password_edit).Text += otp;
}
}
else
{
ResetState();
GetIocFromLaunchIntent(intent);
InitializeAfterSetIoc();
OnStart();
}
}
}
@@ -1744,150 +1739,185 @@ namespace keepass2android
protected override View? SnackbarAnchorView => FindViewById(Resource.Id.main_content);
protected override void OnResume()
{
base.OnResume();
protected override void OnResume()
{
base.OnResume();
_activityDesign.ReapplyTheme();
_activityDesign.ReapplyTheme();
Kp2aLog.Log("starting: " + _starting + ", Finishing: " + IsFinishing + ", _performingLoad: " +
_performingLoad);
Kp2aLog.Log("starting: " + _starting + ", Finishing: " + IsFinishing + ", _performingLoad: " +
_performingLoad);
CheckBox cbOfflineMode = (CheckBox)FindViewById(Resource.Id.work_offline);
App.Kp2a.OfflineMode =
cbOfflineMode.Checked =
App.Kp2a
.OfflineModePreference; //this won't overwrite new user settings because every change is directly saved in settings
LinearLayout offlineModeContainer = FindViewById<LinearLayout>(Resource.Id.work_offline_container);
var cachingFileStorage = App.Kp2a.GetFileStorage(_ioConnection) as CachingFileStorage;
if ((cachingFileStorage != null) && cachingFileStorage.IsCached(_ioConnection))
{
offlineModeContainer.Visibility = ViewStates.Visible;
}
else
{
offlineModeContainer.Visibility = ViewStates.Gone;
App.Kp2a.OfflineMode = false;
}
CheckBox cbOfflineMode = (CheckBox)FindViewById(Resource.Id.work_offline);
App.Kp2a.OfflineMode =
cbOfflineMode.Checked =
App.Kp2a
.OfflineModePreference; //this won't overwrite new user settings because every change is directly saved in settings
LinearLayout offlineModeContainer = FindViewById<LinearLayout>(Resource.Id.work_offline_container);
var cachingFileStorage = App.Kp2a.GetFileStorage(_ioConnection) as CachingFileStorage;
if ((cachingFileStorage != null) && cachingFileStorage.IsCached(_ioConnection))
View killButton = FindViewById(Resource.Id.kill_app);
if (PreferenceManager.GetDefaultSharedPreferences(this)
.GetBoolean(GetString(Resource.String.show_kill_app_key), false))
{
killButton.Click += (sender, args) =>
{
_killOnDestroy = true;
SetResult(Result.Canceled);
Finish();
};
killButton.Visibility = ViewStates.Visible;
}
else
{
killButton.Visibility = ViewStates.Gone;
}
TryGetOtpFromClipboard();
if (!_keepPasswordInOnResume)
{
if (
_lastOnPauseTime <
DateTime.Now -
TimeSpan.FromSeconds(
5) //only clear when user left the app for more than 5 seconds (allows to use Yubiclip, also allows to switch shortly to another app)
&&
PreferenceManager.GetDefaultSharedPreferences(this)
.GetBoolean(GetString(Resource.String.ClearPasswordOnLeave_key), true))
{
ClearEnteredPassword();
}
}
_keepPasswordInOnResume = false;
MakePasswordMaskedOrVisible();
UpdateOkButtonState();
if (KeyProviderTypes.Contains(KeyProviders.Challenge))
{
FindViewById(Resource.Id.otpInitView).Visibility =
_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 !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)
{
offlineModeContainer.Visibility = ViewStates.Visible;
}
else
{
offlineModeContainer.Visibility = ViewStates.Gone;
App.Kp2a.OfflineMode = false;
}
View killButton = FindViewById(Resource.Id.kill_app);
if (PreferenceManager.GetDefaultSharedPreferences(this)
.GetBoolean(GetString(Resource.String.show_kill_app_key), false))
{
killButton.Click += (sender, args) =>
{
_killOnDestroy = true;
SetResult(Result.Canceled);
Finish();
};
killButton.Visibility = ViewStates.Visible;
}
else
{
killButton.Visibility = ViewStates.Gone;
}
TryGetOtpFromClipboard();
if (!_keepPasswordInOnResume)
{
if (
_lastOnPauseTime <
DateTime.Now -
TimeSpan.FromSeconds(
5) //only clear when user left the app for more than 5 seconds (allows to use Yubiclip, also allows to switch shortly to another app)
&&
PreferenceManager.GetDefaultSharedPreferences(this)
.GetBoolean(GetString(Resource.String.ClearPasswordOnLeave_key), true))
{
ClearEnteredPassword();
}
}
_keepPasswordInOnResume = false;
MakePasswordMaskedOrVisible();
UpdateOkButtonState();
if (KeyProviderTypes.Contains(KeyProviders.Challenge))
{
FindViewById(Resource.Id.otpInitView).Visibility =
_challengeSecret == null ? ViewStates.Visible : ViewStates.Gone;
}
//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)
{
// OnResume is run every time the activity comes to the foreground. This code should only run when the activity is started (OnStart), but must
// OnResume is run every time the activity comes to the foreground. This code should only run when the activity is started (OnStart), but must
// be run in OnResume rather than OnStart so that it always occurrs after OnActivityResult (when re-creating a killed activity, OnStart occurs before OnActivityResult)
if (_starting)
{
if (_starting)
{
_starting = false;
_starting = false;
//database not yet loaded.
//database not yet loaded.
//check if pre-loading is enabled but wasn't started yet:
if (_loadDbFileTask == null &&
_prefs.GetBoolean(GetString(Resource.String.PreloadDatabaseEnabled_key), true))
{
// Create task to kick off file loading while the user enters the password
_loadDbFileTask = Task.Factory.StartNew(PreloadDbFile);
_loadDbTaskOffline = App.Kp2a.OfflineMode;
}
}
//check if pre-loading is enabled but wasn't started yet:
if (_loadDbFileTask == null &&
_prefs.GetBoolean(GetString(Resource.String.PreloadDatabaseEnabled_key), true))
{
// Create task to kick off file loading while the user enters the password
_loadDbFileTask = Task.Factory.StartNew(PreloadDbFile);
_loadDbTaskOffline = App.Kp2a.OfflineMode;
}
}
}
if (compositeKeyForImmediateLoad != null)
{
//reload the database (without most other stuff performed in PerformLoadDatabase.
// We're assuming that the db file (and if appropriate also the key file) are still available
// and there's no need to re-init the file storage. if it is, loading will fail and the user has
// to retry with typing the full password, but that's intended to avoid showing the password to a
// a potentially unauthorized user (feature request https://keepass2android.codeplex.com/workitem/274)
Handler handler = new Handler();
OnFinish onFinish = new AfterLoad(handler, this, _ioConnection);
_performingLoad = true;
LoadDb task = new LoadDb(this, App.Kp2a, _ioConnection, _loadDbFileTask, compositeKeyForImmediateLoad, GetKeyProviderString(),
onFinish, false, _makeCurrent);
_loadDbFileTask = null; // prevent accidental re-use
new ProgressTask(App.Kp2a, this, task).Run();
compositeKeyForImmediateLoad = null; //don't reuse or keep in memory
if (compositeKeyForImmediateLoad != null)
{
//reload the database (without most other stuff performed in PerformLoadDatabase.
// We're assuming that the db file (and if appropriate also the key file) are still available
// and there's no need to re-init the file storage. if it is, loading will fail and the user has
// to retry with typing the full password, but that's intended to avoid showing the password to a
// a potentially unauthorized user (feature request https://keepass2android.codeplex.com/workitem/274)
Handler handler = new Handler();
OnFinish onFinish = new AfterLoad(handler, this, _ioConnection);
_performingLoad = true;
LoadDb task = new LoadDb(this, App.Kp2a, _ioConnection, _loadDbFileTask, compositeKeyForImmediateLoad, GetKeyProviderString(),
onFinish, false, _makeCurrent);
_loadDbFileTask = null; // prevent accidental re-use
new ProgressTask(App.Kp2a, this, task).Run();
compositeKeyForImmediateLoad = null; //don't reuse or keep in memory
}
else
{
bool showKeyboard = true;
}
else
{
bool showKeyboard = true;
EditText pwd = (EditText)FindViewById(Resource.Id.password_edit);
pwd.PostDelayed(() =>
{
InputMethodManager keyboard = (InputMethodManager)GetSystemService(InputMethodService);
if (showKeyboard)
{
pwd.RequestFocus();
keyboard.ShowSoftInput(pwd, 0);
}
else
keyboard.HideSoftInputFromWindow(pwd.WindowToken, HideSoftInputFlags.ImplicitOnly);
}, 50);
}
_resumeCompleted = true;
EditText pwd = (EditText) FindViewById(Resource.Id.password_edit);
pwd.PostDelayed(() =>
{
InputMethodManager keyboard = (InputMethodManager) GetSystemService(InputMethodService);
if (showKeyboard)
{
pwd.RequestFocus();
keyboard.ShowSoftInput(pwd, 0);
}
else
keyboard.HideSoftInputFromWindow(pwd.WindowToken, HideSoftInputFlags.ImplicitOnly);
}, 50);
}
}
private void TryGetOtpFromClipboard()

View File

@@ -142,4 +142,146 @@
<color name="md_theme_surfaceContainer_highContrast">#1D2118</color>
<color name="md_theme_surfaceContainerHigh_highContrast">#282B22</color>
<color name="md_theme_surfaceContainerHighest_highContrast">#32362C</color>
<color name="md_theme_lowstim_primary">#91C456</color>
<color name="md_theme_lowstim_onPrimary">#192E00</color>
<color name="md_theme_lowstim_primaryContainer">#719E3A</color>
<color name="md_theme_lowstim_onPrimaryContainer">#112200</color>
<color name="md_theme_lowstim_secondary">#84ACD9</color>
<color name="md_theme_lowstim_onSecondary">#002947</color>
<color name="md_theme_lowstim_secondaryContainer">#005D94</color>
<color name="md_theme_lowstim_onSecondaryContainer">#DEDEDE</color>
<color name="md_theme_lowstim_tertiary">#40B385</color>
<color name="md_theme_lowstim_onTertiary">#002F1E</color>
<color name="md_theme_lowstim_tertiaryContainer">#00A676</color>
<color name="md_theme_lowstim_onTertiaryContainer">#002216</color>
<color name="md_theme_lowstim_error">#D49B94</color>
<color name="md_theme_lowstim_onError">#590004</color>
<color name="md_theme_lowstim_errorContainer">#7D0008</color>
<color name="md_theme_lowstim_onErrorContainer">#D4B9B3</color>
<color name="md_theme_lowstim_background">#0F130A</color>
<color name="md_theme_lowstim_onBackground">#BEE0C4</color>
<color name="md_theme_lowstim_surface">#0F130A</color>
<color name="md_theme_lowstim_onSurface">#BEE0C4</color>
<color name="md_theme_lowstim_surfaceVariant">#383E30</color>
<color name="md_theme_lowstim_onSurfaceVariant">#A6AD99</color>
<color name="md_theme_lowstim_outline">#757B68</color>
<color name="md_theme_lowstim_outlineVariant">#383E30</color>
<color name="md_theme_lowstim_scrim">#000000</color>
<color name="md_theme_lowstim_inverseSurface">#BEE0C4</color>
<color name="md_theme_lowstim_inverseOnSurface">#272B22</color>
<color name="md_theme_lowstim_inversePrimary">#345800</color>
<color name="md_theme_lowstim_primaryFixed">#9ED75B</color>
<color name="md_theme_lowstim_onPrimaryFixed">#0C1B00</color>
<color name="md_theme_lowstim_primaryFixedDim">#82B750</color>
<color name="md_theme_lowstim_onPrimaryFixedVariant">#264200</color>
<color name="md_theme_lowstim_secondaryFixed">#B2D1E5</color>
<color name="md_theme_lowstim_onSecondaryFixed">#00192E</color>
<color name="md_theme_lowstim_secondaryFixedDim">#84ACD9</color>
<color name="md_theme_lowstim_onSecondaryFixedVariant">#003E66</color>
<color name="md_theme_lowstim_tertiaryFixed">#4EC79E</color>
<color name="md_theme_lowstim_onTertiaryFixed">#001D11</color>
<color name="md_theme_lowstim_tertiaryFixedDim">#2EBDA1</color>
<color name="md_theme_lowstim_onTertiaryFixedVariant">#004530</color>
<color name="md_theme_lowstim_surfaceDim">#0F130A</color>
<color name="md_theme_lowstim_surfaceBright">#2E3229</color>
<color name="md_theme_lowstim_surfaceContainerLowest">#0A0D07</color>
<color name="md_theme_lowstim_surfaceContainerLow">#161A11</color>
<color name="md_theme_lowstim_surfaceContainer">#191D14</color>
<color name="md_theme_lowstim_surfaceContainerHigh">#23271E</color>
<color name="md_theme_lowstim_surfaceContainerHighest">#2B2F26</color>
<color name="md_theme_lowstim_primary_mediumContrast">#91C456</color>
<color name="md_theme_lowstim_onPrimary_mediumContrast">#101E00</color>
<color name="md_theme_lowstim_primaryContainer_mediumContrast">#719E3A</color>
<color name="md_theme_lowstim_onPrimaryContainer_mediumContrast">#000000</color>
<color name="md_theme_lowstim_secondary_mediumContrast">#88B3D6</color>
<color name="md_theme_lowstim_onSecondary_mediumContrast">#001524</color>
<color name="md_theme_lowstim_secondaryContainer_mediumContrast">#3481B7</color>
<color name="md_theme_lowstim_onSecondaryContainer_mediumContrast">#000000</color>
<color name="md_theme_lowstim_tertiary_mediumContrast">#40B385</color>
<color name="md_theme_lowstim_onTertiary_mediumContrast">#002216</color>
<color name="md_theme_lowstim_tertiaryContainer_mediumContrast">#00A676</color>
<color name="md_theme_lowstim_onTertiaryContainer_mediumContrast">#000000</color>
<color name="md_theme_lowstim_error_mediumContrast">#D4A29A</color>
<color name="md_theme_lowstim_onError_mediumContrast">#2F0001</color>
<color name="md_theme_lowstim_errorContainer_mediumContrast">#D4463B</color>
<color name="md_theme_lowstim_onErrorContainer_mediumContrast">#000000</color>
<color name="md_theme_lowstim_background_mediumContrast">#0F130A</color>
<color name="md_theme_lowstim_onBackground_mediumContrast">#BEE0C4</color>
<color name="md_theme_lowstim_surface_mediumContrast">#0F130A</color>
<color name="md_theme_lowstim_onSurface_mediumContrast">#D6E6CD</color>
<color name="md_theme_lowstim_surfaceVariant_mediumContrast">#383E30</color>
<color name="md_theme_lowstim_onSurfaceVariant_mediumContrast">#AAB1A0</color>
<color name="md_theme_lowstim_outline_mediumContrast">#888E7B</color>
<color name="md_theme_lowstim_outlineVariant_mediumContrast">#6B7163</color>
<color name="md_theme_lowstim_scrim_mediumContrast">#000000</color>
<color name="md_theme_lowstim_inverseSurface_mediumContrast">#BEE0C4</color>
<color name="md_theme_lowstim_inverseOnSurface_mediumContrast">#23261E</color>
<color name="md_theme_lowstim_inversePrimary_mediumContrast">#294500</color>
<color name="md_theme_lowstim_primaryFixed_mediumContrast">#9ED75B</color>
<color name="md_theme_lowstim_onPrimaryFixed_mediumContrast">#071000</color>
<color name="md_theme_lowstim_primaryFixedDim_mediumContrast">#82B750</color>
<color name="md_theme_lowstim_onPrimaryFixedVariant_mediumContrast">#1D3300</color>
<color name="md_theme_lowstim_secondaryFixed_mediumContrast">#B2D1E5</color>
<color name="md_theme_lowstim_onSecondaryFixed_mediumContrast">#00101D</color>
<color name="md_theme_lowstim_secondaryFixedDim_mediumContrast">#84ACD9</color>
<color name="md_theme_lowstim_onSecondaryFixedVariant_mediumContrast">#003151</color>
<color name="md_theme_lowstim_tertiaryFixed_mediumContrast">#4EC79E</color>
<color name="md_theme_lowstim_onTertiaryFixed_mediumContrast">#001109</color>
<color name="md_theme_lowstim_tertiaryFixedDim_mediumContrast">#2EBDA1</color>
<color name="md_theme_lowstim_onTertiaryFixedVariant_mediumContrast">#003523</color>
<color name="md_theme_lowstim_surfaceDim_mediumContrast">#0F130A</color>
<color name="md_theme_lowstim_surfaceBright_mediumContrast">#2E3229</color>
<color name="md_theme_lowstim_surfaceContainerLowest_mediumContrast">#0A0D07</color>
<color name="md_theme_lowstim_surfaceContainerLow_mediumContrast">#161A11</color>
<color name="md_theme_lowstim_surfaceContainer_mediumContrast">#191D14</color>
<color name="md_theme_lowstim_surfaceContainerHigh_mediumContrast">#23271E</color>
<color name="md_theme_lowstim_surfaceContainerHighest_mediumContrast">#2B2F26</color>
<color name="md_theme_lowstim_primary_highContrast">#D6FF99</color>
<color name="md_theme_lowstim_onPrimary_highContrast">#000000</color>
<color name="md_theme_lowstim_primaryContainer_highContrast">#8AC757</color>
<color name="md_theme_lowstim_onPrimaryContainer_highContrast">#000000</color>
<color name="md_theme_lowstim_secondary_highContrast">#D1D1FF</color>
<color name="md_theme_lowstim_onSecondary_highContrast">#000000</color>
<color name="md_theme_lowstim_secondaryContainer_highContrast">#88B3D6</color>
<color name="md_theme_lowstim_onSecondaryContainer_highContrast">#000000</color>
<color name="md_theme_lowstim_tertiary_highContrast">#B0FFD1</color>
<color name="md_theme_lowstim_onTertiary_highContrast">#000000</color>
<color name="md_theme_lowstim_tertiaryContainer_highContrast">#34B780</color>
<color name="md_theme_lowstim_onTertiaryContainer_highContrast">#000000</color>
<color name="md_theme_lowstim_error_highContrast">#eFDADA</color>
<color name="md_theme_lowstim_onError_highContrast">#000000</color>
<color name="md_theme_lowstim_errorContainer_highContrast">#D4A29A</color>
<color name="md_theme_lowstim_onErrorContainer_highContrast">#000000</color>
<color name="md_theme_lowstim_background_highContrast">#0F130A</color>
<color name="md_theme_lowstim_onBackground_highContrast">#BEE0C4</color>
<color name="md_theme_lowstim_surface_highContrast">#0F130A</color>
<color name="md_theme_lowstim_onSurface_highContrast">#eFeFeF</color>
<color name="md_theme_lowstim_surfaceVariant_highContrast">#383E30</color>
<color name="md_theme_lowstim_onSurfaceVariant_highContrast">#D4E4C6</color>
<color name="md_theme_lowstim_outline_highContrast">#AAB1A0</color>
<color name="md_theme_lowstim_outlineVariant_highContrast">#AAB1A0</color>
<color name="md_theme_lowstim_scrim_highContrast">#000000</color>
<color name="md_theme_lowstim_inverseSurface_highContrast">#BEE0C4</color>
<color name="md_theme_lowstim_inverseOnSurface_highContrast">#000000</color>
<color name="md_theme_lowstim_inversePrimary_highContrast">#152900</color>
<color name="md_theme_lowstim_primaryFixed_highContrast">#C2FF80</color>
<color name="md_theme_lowstim_onPrimaryFixed_highContrast">#000000</color>
<color name="md_theme_lowstim_primaryFixedDim_highContrast">#8AC757</color>
<color name="md_theme_lowstim_onPrimaryFixedVariant_highContrast">#0A1500</color>
<color name="md_theme_lowstim_secondaryFixed_highContrast">#DEDEFF</color>
<color name="md_theme_lowstim_onSecondaryFixed_highContrast">#000000</color>
<color name="md_theme_lowstim_secondaryFixedDim_highContrast">#88B3D6</color>
<color name="md_theme_lowstim_onSecondaryFixedVariant_highContrast">#001524</color>
<color name="md_theme_lowstim_tertiaryFixed_highContrast">#95FFB7</color>
<color name="md_theme_lowstim_onTertiaryFixed_highContrast">#000000</color>
<color name="md_theme_lowstim_tertiaryFixedDim_highContrast">#34B780</color>
<color name="md_theme_lowstim_onTertiaryFixedVariant_highContrast">#00180D</color>
<color name="md_theme_lowstim_surfaceDim_highContrast">#0F130A</color>
<color name="md_theme_lowstim_surfaceBright_highContrast">#2E3229</color>
<color name="md_theme_lowstim_surfaceContainerLowest_highContrast">#0A0D07</color>
<color name="md_theme_lowstim_surfaceContainerLow_highContrast">#161A11</color>
<color name="md_theme_lowstim_surfaceContainer_highContrast">#191D14</color>
<color name="md_theme_lowstim_surfaceContainerHigh_highContrast">#23271E</color>
<color name="md_theme_lowstim_surfaceContainerHighest_highContrast">#2B2F26</color>
</resources>

View File

@@ -142,4 +142,146 @@
<color name="md_theme_surfaceContainer_highContrast">#E9EFF0</color>
<color name="md_theme_surfaceContainerHigh_highContrast">#E3E9EA</color>
<color name="md_theme_surfaceContainerHighest_highContrast">#DEE3E5</color>
<color name="md_theme_lowstim_primary">#3F5625</color>
<color name="md_theme_lowstim_onPrimary">#DEDEDE</color>
<color name="md_theme_lowstim_primaryContainer">#A8C288</color>
<color name="md_theme_lowstim_onPrimaryContainer">#0C1B00</color>
<color name="md_theme_lowstim_secondary">#295377</color>
<color name="md_theme_lowstim_onSecondary">#DEDEDE</color>
<color name="md_theme_lowstim_secondaryContainer">#B2D1E5</color>
<color name="md_theme_lowstim_onSecondaryContainer">#00192E</color>
<color name="md_theme_lowstim_tertiary">#325653</color>
<color name="md_theme_lowstim_onTertiary">#DEDEDE</color>
<color name="md_theme_lowstim_tertiaryContainer">#98B2B0</color>
<color name="md_theme_lowstim_onTertiaryContainer">#001B1A</color>
<color name="md_theme_lowstim_error">#9F1717</color>
<color name="md_theme_lowstim_onError">#DEDEDE</color>
<color name="md_theme_lowstim_errorContainer">#D4B9B3</color>
<color name="md_theme_lowstim_onErrorContainer">#370002</color>
<color name="md_theme_lowstim_background">#D6D6D6</color>
<color name="md_theme_lowstim_onBackground">#171913</color>
<color name="md_theme_lowstim_surface">#D2D9DA</color>
<color name="md_theme_lowstim_onSurface">#141819</color>
<color name="md_theme_lowstim_surfaceVariant">#B9BDB6</color>
<color name="md_theme_lowstim_onSurfaceVariant">#3B4034</color>
<color name="md_theme_lowstim_outline">#64675B</color>
<color name="md_theme_lowstim_outlineVariant">#A8ABA2</color>
<color name="md_theme_lowstim_scrim">#000000</color>
<color name="md_theme_lowstim_inverseSurface">#252A2B</color>
<color name="md_theme_lowstim_inverseOnSurface">#C7CFCF</color>
<color name="md_theme_lowstim_inversePrimary">#94B173</color>
<color name="md_theme_lowstim_primaryFixed">#A8C288</color>
<color name="md_theme_lowstim_onPrimaryFixed">#0C1B00</color>
<color name="md_theme_lowstim_primaryFixedDim">#94B173</color>
<color name="md_theme_lowstim_onPrimaryFixedVariant">#2E4114</color>
<color name="md_theme_lowstim_secondaryFixed">#B2D1E5</color>
<color name="md_theme_lowstim_onSecondaryFixed">#00192E</color>
<color name="md_theme_lowstim_secondaryFixedDim">#84ACD9</color>
<color name="md_theme_lowstim_onSecondaryFixedVariant">#104064</color>
<color name="md_theme_lowstim_tertiaryFixed">#98B2B0</color>
<color name="md_theme_lowstim_onTertiaryFixed">#001B1A</color>
<color name="md_theme_lowstim_tertiaryFixedDim">#88B2AF</color>
<color name="md_theme_lowstim_onTertiaryFixedVariant">#1A423F</color>
<color name="md_theme_lowstim_surfaceDim">#B6BEC0</color>
<color name="md_theme_lowstim_surfaceBright">#D2D9DA</color>
<color name="md_theme_lowstim_surfaceContainerLowest">#DEDEDE</color>
<color name="md_theme_lowstim_surfaceContainerLow">#CEDAEC</color>
<color name="md_theme_lowstim_surfaceContainer">#CAD0D1</color>
<color name="md_theme_lowstim_surfaceContainerHigh">#C9D1D2</color>
<color name="md_theme_lowstim_surfaceContainerHighest">#C0C9C7</color>
<color name="md_theme_lowstim_primary_mediumContrast">#2A3F0E</color>
<color name="md_theme_lowstim_onPrimary_mediumContrast">#DEDEDE</color>
<color name="md_theme_lowstim_primaryContainer_mediumContrast">#526B36</color>
<color name="md_theme_lowstim_onPrimaryContainer_mediumContrast">#DEDEDE</color>
<color name="md_theme_lowstim_secondary_mediumContrast">#0A3E5F</color>
<color name="md_theme_lowstim_onSecondary_mediumContrast">#DEDEDE</color>
<color name="md_theme_lowstim_secondaryContainer_mediumContrast">#3E698D</color>
<color name="md_theme_lowstim_onSecondaryContainer_mediumContrast">#DEDEDE</color>
<color name="md_theme_lowstim_tertiary_mediumContrast">#173F3D</color>
<color name="md_theme_lowstim_onTertiary_mediumContrast">#DEDEDE</color>
<color name="md_theme_lowstim_tertiaryContainer_mediumContrast">#426A66</color>
<color name="md_theme_lowstim_onTertiaryContainer_mediumContrast">#DEDEDE</color>
<color name="md_theme_lowstim_error_mediumContrast">#750008</color>
<color name="md_theme_lowstim_onError_mediumContrast">#DEDEDE</color>
<color name="md_theme_lowstim_errorContainer_mediumContrast">#B92F28</color>
<color name="md_theme_lowstim_onErrorContainer_mediumContrast">#DEDEDE</color>
<color name="md_theme_lowstim_background_mediumContrast">#D6D7D0</color>
<color name="md_theme_lowstim_onBackground_mediumContrast">#171913</color>
<color name="md_theme_lowstim_surface_mediumContrast">#D2D9DA</color>
<color name="md_theme_lowstim_onSurface_mediumContrast">#141819</color>
<color name="md_theme_lowstim_surfaceVariant_mediumContrast">#B9BDB6</color>
<color name="md_theme_lowstim_onSurfaceVariant_mediumContrast">#363B30</color>
<color name="md_theme_lowstim_outline_mediumContrast">#4F5347</color>
<color name="md_theme_lowstim_outlineVariant_mediumContrast">#696D61</color>
<color name="md_theme_lowstim_scrim_mediumContrast">#000000</color>
<color name="md_theme_lowstim_inverseSurface_mediumContrast">#252A2B</color>
<color name="md_theme_lowstim_inverseOnSurface_mediumContrast">#C7CFCF</color>
<color name="md_theme_lowstim_inversePrimary_mediumContrast">#94B173</color>
<color name="md_theme_lowstim_primaryFixed_mediumContrast">#526B36</color>
<color name="md_theme_lowstim_onPrimaryFixed_mediumContrast">#DEDEDE</color>
<color name="md_theme_lowstim_primaryFixedDim_mediumContrast">#3B531F</color>
<color name="md_theme_lowstim_onPrimaryFixedVariant_mediumContrast">#DEDEDE</color>
<color name="md_theme_lowstim_secondaryFixed_mediumContrast">#3E698D</color>
<color name="md_theme_lowstim_onSecondaryFixed_mediumContrast">#DEDEDE</color>
<color name="md_theme_lowstim_secondaryFixedDim_mediumContrast">#295377</color>
<color name="md_theme_lowstim_onSecondaryFixedVariant_mediumContrast">#DEDEDE</color>
<color name="md_theme_lowstim_tertiaryFixed_mediumContrast">#426A66</color>
<color name="md_theme_lowstim_onTertiaryFixed_mediumContrast">#DEDEDE</color>
<color name="md_theme_lowstim_tertiaryFixedDim_mediumContrast">#2E5350</color>
<color name="md_theme_lowstim_onTertiaryFixedVariant_mediumContrast">#DEDEDE</color>
<color name="md_theme_lowstim_surfaceDim_mediumContrast">#B6BEC0</color>
<color name="md_theme_lowstim_surfaceBright_mediumContrast">#D2D9DA</color>
<color name="md_theme_lowstim_surfaceContainerLowest_mediumContrast">#DEDEDE</color>
<color name="md_theme_lowstim_surfaceContainerLow_mediumContrast">#CEDAEC</color>
<color name="md_theme_lowstim_surfaceContainer_mediumContrast">#CAD0D1</color>
<color name="md_theme_lowstim_surfaceContainerHigh_mediumContrast">#C9D1D2</color>
<color name="md_theme_lowstim_surfaceContainerHighest_mediumContrast">#C0C9C7</color>
<color name="md_theme_lowstim_primary_highContrast">#051400</color>
<color name="md_theme_lowstim_onPrimary_highContrast">#DEDEDE</color>
<color name="md_theme_lowstim_primaryContainer_highContrast">#0F2000</color>
<color name="md_theme_lowstim_onPrimaryContainer_highContrast">#DEDEDE</color>
<color name="md_theme_lowstim_secondary_highContrast">#000F1D</color>
<color name="md_theme_lowstim_onSecondary_highContrast">#DEDEDE</color>
<color name="md_theme_lowstim_secondaryContainer_highContrast">#0B466F</color>
<color name="md_theme_lowstim_onSecondaryContainer_highContrast">#DEDEDE</color>
<color name="md_theme_lowstim_tertiary_highContrast">#001312</color>
<color name="md_theme_lowstim_onTertiary_highContrast">#DEDEDE</color>
<color name="md_theme_lowstim_tertiaryContainer_highContrast">#1A4A47</color>
<color name="md_theme_lowstim_onTertiaryContainer_highContrast">#DEDEDE</color>
<color name="md_theme_lowstim_error_highContrast">#170001</color>
<color name="md_theme_lowstim_onError_highContrast">#DEDEDE</color>
<color name="md_theme_lowstim_errorContainer_highContrast">#2A0004</color>
<color name="md_theme_lowstim_onErrorContainer_highContrast">#DEDEDE</color>
<color name="md_theme_lowstim_background_highContrast">#D6D7D0</color>
<color name="md_theme_lowstim_onBackground_highContrast">#171913</color>
<color name="md_theme_lowstim_surface_highContrast">#D2D9DA</color>
<color name="md_theme_lowstim_onSurface_highContrast">#000000</color>
<color name="md_theme_lowstim_surfaceVariant_highContrast">#B9BDB6</color>
<color name="md_theme_lowstim_onSurfaceVariant_highContrast">#1B1E17</color>
<color name="md_theme_lowstim_outline_highContrast">#363B30</color>
<color name="md_theme_lowstim_outlineVariant_highContrast">#363B30</color>
<color name="md_theme_lowstim_scrim_highContrast">#000000</color>
<color name="md_theme_lowstim_inverseSurface_highContrast">#252A2B</color>
<color name="md_theme_lowstim_inverseOnSurface_highContrast">#DEDEDE</color>
<color name="md_theme_lowstim_inversePrimary_highContrast">#B1D18A</color>
<color name="md_theme_lowstim_primaryFixed_highContrast">#0F2000</color>
<color name="md_theme_lowstim_onPrimaryFixed_highContrast">#DEDEDE</color>
<color name="md_theme_lowstim_primaryFixedDim_highContrast">#071700</color>
<color name="md_theme_lowstim_onPrimaryFixedVariant_highContrast">#DEDEDE</color>
<color name="md_theme_lowstim_secondaryFixed_highContrast">#0B466F</color>
<color name="md_theme_lowstim_onSecondaryFixed_highContrast">#DEDEDE</color>
<color name="md_theme_lowstim_secondaryFixedDim_highContrast">#002643</color>
<color name="md_theme_lowstim_onSecondaryFixedVariant_highContrast">#DEDEDE</color>
<color name="md_theme_lowstim_tertiaryFixed_highContrast">#1A4A47</color>
<color name="md_theme_lowstim_onTertiaryFixed_highContrast">#DEDEDE</color>
<color name="md_theme_lowstim_tertiaryFixedDim_highContrast">#001D1B</color>
<color name="md_theme_lowstim_onTertiaryFixedVariant_highContrast">#DEDEDE</color>
<color name="md_theme_lowstim_surfaceDim_highContrast">#B6BEC0</color>
<color name="md_theme_lowstim_surfaceBright_highContrast">#D2D9DA</color>
<color name="md_theme_lowstim_surfaceContainerLowest_highContrast">#DEDEDE</color>
<color name="md_theme_lowstim_surfaceContainerLow_highContrast">#CEDAEC</color>
<color name="md_theme_lowstim_surfaceContainer_highContrast">#CAD0D1</color>
<color name="md_theme_lowstim_surfaceContainerHigh_highContrast">#C9D1D2</color>
<color name="md_theme_lowstim_surfaceContainerHighest_highContrast">#C0C9C7</color>
</resources>

View File

@@ -73,6 +73,8 @@
<string name="omitbackup_key">omitbackup</string>
<string name="list_size_key">list_size</string>
<string name="design_key">design_key</string>
<string name="LowStimulus_key">LowStimulus_key</string>
<string name="app_language_pref_key">app_language_pref_key</string>
<string name="sort_key_old">sort_key</string>
<string name="sort_key">sort_key_new</string>

View File

@@ -1253,5 +1253,7 @@
<string name="switch_keyboard_for_totp_enabled">Note: You have enabled App - Password access - Autofill-Service - Autofill for TOTP entries. This can cause this window to show when you open an entry with a TOTP.</string>
<string name="switch_keyboard_inside_kp2a_enabled">Note: You have enabled App - Security - Use built-in keyboard inside Keepass2Android. This can cause this window to show when you open the app or edit an entry.</string>
<string name="switch_keyboard_on_search_enabled">Note: You have enabled App - Security - Password access - Keyboard switching - Switch keyboard. This can cause this window to show when you search for an entry from the browser.</string>
<string name="LowStimulus_title">Low stimulus mode</string>
<string name="LowStimulus_summary">Enable low stimulus mode</string>
</resources>

View File

@@ -261,6 +261,56 @@
</style>
<style name="OverlayLowStimulation" parent="">
<item name="colorPrimary">@color/md_theme_lowstim_primary</item>
<item name="colorOnPrimary">@color/md_theme_lowstim_onPrimary</item>
<item name="colorPrimaryContainer">@color/md_theme_lowstim_primaryContainer</item>
<item name="colorOnPrimaryContainer">@color/md_theme_lowstim_onPrimaryContainer</item>
<item name="colorSecondary">@color/md_theme_lowstim_secondary</item>
<item name="colorOnSecondary">@color/md_theme_lowstim_onSecondary</item>
<item name="colorSecondaryContainer">@color/md_theme_lowstim_secondaryContainer</item>
<item name="colorOnSecondaryContainer">@color/md_theme_lowstim_onSecondaryContainer</item>
<item name="colorTertiary">@color/md_theme_lowstim_tertiary</item>
<item name="colorOnTertiary">@color/md_theme_lowstim_onTertiary</item>
<item name="colorTertiaryContainer">@color/md_theme_lowstim_tertiaryContainer</item>
<item name="colorOnTertiaryContainer">@color/md_theme_lowstim_onTertiaryContainer</item>
<item name="colorError">@color/md_theme_lowstim_error</item>
<item name="colorOnError">@color/md_theme_lowstim_onError</item>
<item name="colorErrorContainer">@color/md_theme_lowstim_errorContainer</item>
<item name="colorOnErrorContainer">@color/md_theme_lowstim_onErrorContainer</item>
<item name="android:colorBackground">@color/md_theme_lowstim_background</item>
<item name="colorOnBackground">@color/md_theme_lowstim_onBackground</item>
<item name="colorSurface">@color/md_theme_lowstim_surface</item>
<item name="colorOnSurface">@color/md_theme_lowstim_onSurface</item>
<item name="colorSurfaceVariant">@color/md_theme_lowstim_surfaceVariant</item>
<item name="colorOnSurfaceVariant">@color/md_theme_lowstim_onSurfaceVariant</item>
<item name="colorOutline">@color/md_theme_lowstim_outline</item>
<item name="colorOutlineVariant">@color/md_theme_lowstim_outlineVariant</item>
<item name="colorSurfaceInverse">@color/md_theme_lowstim_inverseSurface</item>
<item name="colorOnSurfaceInverse">@color/md_theme_lowstim_inverseOnSurface</item>
<item name="colorPrimaryInverse">@color/md_theme_lowstim_inversePrimary</item>
<item name="colorPrimaryFixed">@color/md_theme_lowstim_primaryFixed</item>
<item name="colorOnPrimaryFixed">@color/md_theme_lowstim_onPrimaryFixed</item>
<item name="colorPrimaryFixedDim">@color/md_theme_lowstim_primaryFixedDim</item>
<item name="colorOnPrimaryFixedVariant">@color/md_theme_lowstim_onPrimaryFixedVariant</item>
<item name="colorSecondaryFixed">@color/md_theme_lowstim_secondaryFixed</item>
<item name="colorOnSecondaryFixed">@color/md_theme_lowstim_onSecondaryFixed</item>
<item name="colorSecondaryFixedDim">@color/md_theme_lowstim_secondaryFixedDim</item>
<item name="colorOnSecondaryFixedVariant">@color/md_theme_lowstim_onSecondaryFixedVariant</item>
<item name="colorTertiaryFixed">@color/md_theme_lowstim_tertiaryFixed</item>
<item name="colorOnTertiaryFixed">@color/md_theme_lowstim_onTertiaryFixed</item>
<item name="colorTertiaryFixedDim">@color/md_theme_lowstim_tertiaryFixedDim</item>
<item name="colorOnTertiaryFixedVariant">@color/md_theme_lowstim_onTertiaryFixedVariant</item>
<item name="colorSurfaceDim">@color/md_theme_lowstim_surfaceDim</item>
<item name="colorSurfaceBright">@color/md_theme_lowstim_surfaceBright</item>
<item name="colorSurfaceContainerLowest">@color/md_theme_lowstim_surfaceContainerLowest</item>
<item name="colorSurfaceContainerLow">@color/md_theme_lowstim_surfaceContainerLow</item>
<item name="colorSurfaceContainer">@color/md_theme_lowstim_surfaceContainer</item>
<item name="colorSurfaceContainerHigh">@color/md_theme_lowstim_surfaceContainerHigh</item>
<item name="colorSurfaceContainerHighest">@color/md_theme_lowstim_surfaceContainerHighest</item>
</style>
<style name="Widget.Kp2a.Toolbar" parent="Widget.Material3.Toolbar.OnSurface" />
<style name="Widget.Kp2a.Toolbar.WithCloseButton">

View File

@@ -60,6 +60,15 @@
android:dialogTitle="@string/design_title"
android:defaultValue="@string/design_default" />
<CheckBoxPreference
android:enabled="true"
android:persistent="true"
android:summary="@string/LowStimulus_summary"
android:defaultValue="false"
android:title="@string/LowStimulus_title"
android:key="@string/LowStimulus_key" />
<ListPreference
android:key="@string/app_language_pref_key"
android:title="@string/app_language_pref_title"

View File

@@ -1,6 +1,7 @@
using System;
using System.Linq;
using Android.App;
using Android.Content;
using Android.Content.Res;
using Android.OS;
using Android.Preferences;
@@ -49,6 +50,11 @@ namespace keepass2android
{
_currentThemeId = NightModePreference;
AppCompatDelegate.DefaultNightMode = _currentThemeId.Value;
if (PreferenceManager.GetDefaultSharedPreferences(_activity).GetBoolean(_activity.GetString(Resource.String.LowStimulus_key), false))
{
_activity.SetTheme(Resource.Style.OverlayLowStimulation);
}
_secureWindow = SecureWindowPref();
_currentIconSet = PreferenceManager.GetDefaultSharedPreferences(_activity)

View File

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

View File

@@ -57,6 +57,12 @@ private static Drawable _blank;
if (draw != null)
{
draw = draw.Mutate();
if (PreferenceManager.GetDefaultSharedPreferences(context).GetBoolean(context.GetString(Resource.String.LowStimulus_key), false))
{
Android.Graphics.PorterDuff.Mode mMode = Android.Graphics.PorterDuff.Mode.Multiply;
Color color = new Color(220, 220, 220);
draw.SetColorFilter(color, mMode);
}
iv.SetImageDrawable(draw);
}

View File

@@ -732,12 +732,6 @@
<ItemGroup>
<AndroidNativeLibrary Include="..\java\argon2\libs\armeabi-v7a\libargon2.so" Link="armeabi-v7a\libargon2.so" />
</ItemGroup>
<ItemGroup>
<AndroidNativeLibrary Include="..\java\argon2\libs\x86\libargon2.so" Link="x86\libargon2.so" />
</ItemGroup>
<ItemGroup>
<AndroidNativeLibrary Include="..\java\argon2\libs\x86_64\libargon2.so" Link="x86_64\libargon2.so" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Xamarin.AndroidX.AppCompat" Version="1.7.0.5" />
<PackageReference Include="Xamarin.AndroidX.AppCompat.AppCompatResources" Version="1.7.0.5" />