Compare commits

...

6 Commits

Author SHA1 Message Date
Philipp Crocoll
3f13d55dd8 stability improvements 2025-08-19 12:23:20 +02:00
Philipp Crocoll
b0ad8c3587 manifest for 1.13-r1 2025-07-29 17:36:51 +02:00
Philipp Crocoll
edb4907bf5 add option to disable QuickUnlock blocking behavior, closes #2960 2025-07-29 10:53:02 +02:00
Philipp Crocoll
a718c7ed7e fix quickunlock layout also when showing the "blocked" message 2025-07-29 10:50:43 +02:00
Philipp Crocoll
4f11789f26 remove no longer used file 2025-07-29 10:22:37 +02:00
Philipp Crocoll
eb15861b13 fix QuickUnlock layout to close #2956 2025-07-29 10:22:18 +02:00
13 changed files with 68 additions and 91 deletions

View File

@@ -12,20 +12,21 @@ namespace KeePass.Util
public static string GetErrorMessage(Exception e)
{
string errorMessage = e.Message;
if (e is Java.Lang.Exception javaException)
try
{
try
string errorMessage = e.Message;
if (e is Java.Lang.Exception javaException)
{
errorMessage = javaException.LocalizedMessage ?? javaException.Message ?? errorMessage;
}
finally
{
}
return errorMessage;
}
catch
{
return "";
}
return errorMessage;
}
}

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="222"
android:versionName="1.13-r0"
android:versionCode="235"
android:versionName="1.13-r1"
package="keepass2android.keepass2android"
xmlns:tools="http://schemas.android.com/tools"
android:installLocation="auto">

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="222"
android:versionName="1.13-r0"
android:versionCode="235"
android:versionName="1.13-r1"
package="keepass2android.keepass2android_nonet"
xmlns:tools="http://schemas.android.com/tools"
android:installLocation="auto">

View File

@@ -1425,18 +1425,20 @@ namespace keepass2android
App.Kp2a.SetQuickUnlockEnabled(cbQuickUnlock.Checked);
App.Kp2a.ScreenLockWasEnabledWhenOpeningDatabase =
(((KeyguardManager)GetSystemService(Context.KeyguardService)!)!).IsDeviceSecure;
App.Kp2a.QuickUnlockBlockedWhenDeviceNotSecureWhenOpeningDatabase = PreferenceManager.GetDefaultSharedPreferences(this)
.GetBoolean(GetString(Resource.String.QuickUnlockBlockedWhenDeviceNotSecure_key), true);
if ((_loadDbFileTask != null) && (App.Kp2a.OfflineMode != _loadDbTaskOffline))
if ((_loadDbFileTask != null) && (App.Kp2a.OfflineMode != _loadDbTaskOffline))
{
if (App.Kp2a == null)
if (App.Kp2a == null)
throw new NullPointerException("App.Kp2a");
//keep the loading result if we loaded in online-mode (now offline) and the task is completed
if (!App.Kp2a.OfflineMode || !_loadDbFileTask.IsCompleted)
{
//discard the pre-loading task
_loadDbFileTask = null;
_loadDbFileTask = null;
}
}
//avoid password being visible while loading:

View File

@@ -175,7 +175,7 @@ namespace keepass2android
App.Kp2a.Lock(false);
};
if (App.Kp2a.ScreenLockWasEnabledWhenOpeningDatabase == false)
if (App.Kp2a.ScreenLockWasEnabledWhenOpeningDatabase == false && App.Kp2a.QuickUnlockBlockedWhenDeviceNotSecureWhenOpeningDatabase)
{
FindViewById(Resource.Id.QuickUnlockForm).Visibility = ViewStates.Gone;
FindViewById(Resource.Id.QuickUnlockBlocked).Visibility = ViewStates.Visible;

View File

@@ -78,11 +78,11 @@ android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:orientation="vertical"
android:id="@+id/QuickUnlockForm">
<TextView
@@ -94,6 +94,12 @@ android:paddingRight="16dp"
android:textSize="14sp"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:inputType="textPassword"
android:layout_width="wrap_content"
@@ -117,8 +123,8 @@ android:paddingRight="16dp"
android:src="@drawable/baseline_fingerprint_24"
android:scaleType="fitXY"
android:background="?android:selectableItemBackground" />
</LinearLayout>
</LinearLayout>

View File

@@ -1,61 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="12dip">
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/sftp_host"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:inputType="textNoSuggestions"
android:text="144.76.169.229"
android:hint="@string/hint_sftp_host" />
<TextView
android:id="@+id/portsep"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=":" />
<EditText
android:id="@+id/sftp_port"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:inputType="number"
android:text="22"
android:hint="@string/hint_sftp_port" />
</LinearLayout>
<EditText
android:id="@+id/sftp_user"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:text="philipp"
android:hint="@string/hint_username" />
<EditText
android:id="@+id/sftp_password"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:singleLine="true"
android:text="l2uientTjVhvyfzNpksa"
android:hint="@string/hint_pass" />
<TextView
android:id="@+id/initial_dir"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="4dip"
android:layout_marginTop="4dip"
android:text="@string/initial_directory" />
<EditText
android:id="@+id/sftp_initial_dir"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:text="/home/philipp" />
</LinearLayout>

View File

@@ -123,6 +123,7 @@
<string name="QuickUnlockLength_default">3</string>
<string name="QuickUnlockIconHidden_key">QuickUnlockIconHidden_key</string>
<string name="QuickUnlockIconHidden16_key">QuickUnlockIconHidden16_key</string>
<string name="QuickUnlockBlockedWhenDeviceNotSecure_key">QuickUnlockBlockedWhenDeviceNotSecure_key</string>
<string name="UsageCount_key">UsageCount</string>
<string name="LastInfoVersionCode_key">LastInfoVersion</string>

View File

@@ -330,6 +330,8 @@
<string name="QuickUnlockIconHidden_summary">QuickUnlock unfortunately does not work without displaying a notification icon. Select this option to use a transparent icon.</string>
<string name="QuickUnlockIconHidden16_title">Hide QuickUnlock icon</string>
<string name="QuickUnlockIconHidden16_summary">QuickUnlock requires a notification to work properly. Select this option to display a notification without an icon.</string>
<string name="QuickUnlockBlockedWhenDeviceNotSecure_summary">Block entering the QuickUnlock key if the device is not secured by screen lock. This prevents shoulder surfing attacks. Only disable this option if you understand the risk. Note that QuickUnlock can still be used with biometrics.</string>
<string name="QuickUnlockBlockedWhenDeviceNotSecure_title">Block QuickUnlock when device is not secure</string>
<string name="QuickUnlockLength_title">Length of QuickUnlock key</string>
<string name="QuickUnlockLength_summary">Maximum number of characters used as QuickUnlock password.</string>
<string name="QuickUnlockHideLength_title">Hide QuickUnlock length</string>

View File

@@ -26,6 +26,14 @@
android:defaultValue="false"
android:title="@string/QuickUnlockIconHidden_title"
android:key="@string/QuickUnlockIconHidden_key" />
<CheckBoxPreference
android:enabled="true"
android:persistent="true"
android:summary="@string/QuickUnlockBlockedWhenDeviceNotSecure_summary"
android:defaultValue="true"
android:title="@string/QuickUnlockBlockedWhenDeviceNotSecure_title"
android:key="@string/QuickUnlockBlockedWhenDeviceNotSecure_key" />
<CheckBoxPreference
android:enabled="true"
android:persistent="true"

View File

@@ -352,6 +352,7 @@ namespace keepass2android
}
public bool ScreenLockWasEnabledWhenOpeningDatabase { get; set; }
public bool QuickUnlockBlockedWhenDeviceNotSecureWhenOpeningDatabase { get; set; }
public bool QuickUnlockEnabled { get; private set; }

View File

@@ -131,7 +131,15 @@ namespace keepass2android.view
ev.FindViewById(Resource.Id.icon).Visibility = ViewStates.Visible;
ev.FindViewById(Resource.Id.check_mark).Visibility = ViewStates.Invisible;
_db = App.Kp2a.FindDatabaseForElement(_entry);
_db = App.Kp2a.TryFindDatabaseForElement(_entry);
if (_db == null)
{
ev.FindViewById(Resource.Id.icon).Visibility = ViewStates.Gone;
_textView.TextFormatted = new SpannableString("(no data)");
_textviewDetails.Visibility = ViewStates.Gone;
_textgroupFullPath.Visibility = ViewStates.Gone;
return;
}
ImageView iv = (ImageView)ev.FindViewById(Resource.Id.icon);
bool isExpired = pw.Expires && pw.ExpiryTime < DateTime.Now;
@@ -209,11 +217,6 @@ namespace keepass2android.view
UpdateTotp();
}
public void ConvertView(PwEntry pw, int pos)

View File

@@ -15,14 +15,15 @@ This file is part of Keepass2Android, Copyright 2013 Philipp Crocoll. This file
along with Keepass2Android. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using Android.Graphics;
using Android.OS;
using Android.Runtime;
using Android.Text;
using Android.Views;
using Android.Widget;
using keepass2android;
using KeePassLib;
using System;
using Object = Java.Lang.Object;
namespace keepass2android.view
@@ -64,7 +65,20 @@ namespace keepass2android.view
_label = (TextView) gv.FindViewById(Resource.Id.group_label);
_label.TextSize = size-8;
Database db = App.Kp2a.FindDatabaseForElement(pw);
Database db = App.Kp2a.TryFindDatabaseForElement(pw);
if (db == null)
{
gv.FindViewById(Resource.Id.group_icon_bkg).Visibility = ViewStates.Gone;
gv.FindViewById(Resource.Id.icon).Visibility = ViewStates.Gone;
gv.FindViewById(Resource.Id.check_mark).Visibility = ViewStates.Invisible;
_textview.Text = "(no data)";
_label.Text = "";
return;
}
gv.FindViewById(Resource.Id.group_icon_bkg).Visibility = db.DrawableFactory.IsWhiteIconSet ? ViewStates.Visible : ViewStates.Gone;