From fc832dd3dc019e28dc36a8c76747220e90dc4358 Mon Sep 17 00:00:00 2001 From: Philipp Crocoll Date: Mon, 1 Dec 2014 07:32:12 +0100 Subject: [PATCH] added option (enabled by default) to set FLAG_SECURE (prevent taking screenshots and displaying screenshots in recent apps) --- src/keepass2android/LockCloseActivity.cs | 10 ++++++++++ src/keepass2android/LockCloseListActivity.cs | 8 ++++++++ src/keepass2android/Resources/values/config.xml | 2 +- src/keepass2android/Resources/values/strings.xml | 2 ++ src/keepass2android/Resources/xml/preferences.xml | 9 +++++++++ 5 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/keepass2android/LockCloseActivity.cs b/src/keepass2android/LockCloseActivity.cs index e716e472..245502be 100644 --- a/src/keepass2android/LockCloseActivity.cs +++ b/src/keepass2android/LockCloseActivity.cs @@ -18,7 +18,9 @@ This file is part of Keepass2Android, Copyright 2013 Philipp Crocoll. This file using System; using Android.Content; using Android.OS; +using Android.Preferences; using Android.Runtime; +using Android.Views; using KeePassLib.Serialization; namespace keepass2android @@ -52,6 +54,14 @@ namespace keepass2android { base.OnCreate(savedInstanceState); _design.ApplyTheme(); + + if (PreferenceManager.GetDefaultSharedPreferences(this).GetBoolean( + GetString(Resource.String.ViewDatabaseSecure_key), true)) + { + Window.SetFlags(WindowManagerFlags.Secure, WindowManagerFlags.Secure); + } + + _ioc = App.Kp2a.GetDb().Ioc; if (Intent.GetBooleanExtra(NoLockCheck, false)) diff --git a/src/keepass2android/LockCloseListActivity.cs b/src/keepass2android/LockCloseListActivity.cs index a1496a05..8390e5e8 100644 --- a/src/keepass2android/LockCloseListActivity.cs +++ b/src/keepass2android/LockCloseListActivity.cs @@ -20,6 +20,7 @@ using Android.Content; using Android.OS; using Android.Preferences; using Android.Runtime; +using Android.Views; using KeePassLib.Serialization; namespace keepass2android @@ -42,6 +43,13 @@ namespace keepass2android { base.OnCreate(savedInstanceState); _design.ApplyTheme(); + + if (PreferenceManager.GetDefaultSharedPreferences(this).GetBoolean( + GetString(Resource.String.ViewDatabaseSecure_key), true)) + { + Window.SetFlags(WindowManagerFlags.Secure, WindowManagerFlags.Secure); + } + _ioc = App.Kp2a.GetDb().Ioc; _intentReceiver = new LockCloseListActivityBroadcastReceiver(this); diff --git a/src/keepass2android/Resources/values/config.xml b/src/keepass2android/Resources/values/config.xml index 0d6a22dd..d7e5f0ca 100644 --- a/src/keepass2android/Resources/values/config.xml +++ b/src/keepass2android/Resources/values/config.xml @@ -72,7 +72,7 @@ true true true - + ViewDatabaseSecure true TrayTotp_SettingsField_key TrayTotp_SeedField_key diff --git a/src/keepass2android/Resources/values/strings.xml b/src/keepass2android/Resources/values/strings.xml index 5b3f891e..1de6fcf2 100644 --- a/src/keepass2android/Resources/values/strings.xml +++ b/src/keepass2android/Resources/values/strings.xml @@ -229,6 +229,8 @@ Close database Enable QuickUnlock by default Defines whether QuickUnlock is enabled by default or not. + Protect database display + Protect database display Hide QuickUnlock icon QuickUnlock unfortunately does not work without displaying a notification icon. Select this option to use a transparent icon. Hide QuickUnlock icon diff --git a/src/keepass2android/Resources/xml/preferences.xml b/src/keepass2android/Resources/xml/preferences.xml index 5e7dec2e..72315b03 100644 --- a/src/keepass2android/Resources/xml/preferences.xml +++ b/src/keepass2android/Resources/xml/preferences.xml @@ -160,6 +160,15 @@ android:dialogTitle="@string/list_size_summary" android:defaultValue="@string/list_size_default"/> + + +