allow to hide softkeyboard during fingerprint scan

also support x86_64
add donate reminder
This commit is contained in:
Philipp Crocoll 2016-08-23 04:20:54 +02:00
parent 4583259f45
commit 64f1c63f42
12 changed files with 116 additions and 32 deletions

View File

@ -10,7 +10,8 @@
<RootNamespace>AndroidFileChooserBinding</RootNamespace> <RootNamespace>AndroidFileChooserBinding</RootNamespace>
<AssemblyName>AndroidFileChooserBinding</AssemblyName> <AssemblyName>AndroidFileChooserBinding</AssemblyName>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<TargetFrameworkVersion>v5.0</TargetFrameworkVersion> <TargetFrameworkVersion>v6.0</TargetFrameworkVersion>
<AndroidUseLatestPlatformSdk>True</AndroidUseLatestPlatformSdk>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>

View File

@ -10,7 +10,8 @@
<RootNamespace>KP2AKdbLibraryBinding</RootNamespace> <RootNamespace>KP2AKdbLibraryBinding</RootNamespace>
<AssemblyName>KP2AKdbLibraryBinding</AssemblyName> <AssemblyName>KP2AKdbLibraryBinding</AssemblyName>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<TargetFrameworkVersion>v5.0</TargetFrameworkVersion> <TargetFrameworkVersion>v6.0</TargetFrameworkVersion>
<AndroidUseLatestPlatformSdk>True</AndroidUseLatestPlatformSdk>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>

View File

@ -26,6 +26,7 @@ namespace keepass2android
AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(ctx, Android.Resource.Style.ThemeHoloLightDialog)); AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(ctx, Android.Resource.Style.ThemeHoloLightDialog));
builder.SetTitle(ctx.GetString(Resource.String.ChangeLog_title)); builder.SetTitle(ctx.GetString(Resource.String.ChangeLog_title));
List<string> changeLog = new List<string>{ List<string> changeLog = new List<string>{
ctx.GetString(Resource.String.ChangeLog_1_0_0e),
ctx.GetString(Resource.String.ChangeLog_1_0_0), ctx.GetString(Resource.String.ChangeLog_1_0_0),
ctx.GetString(Resource.String.ChangeLog_0_9_9c), ctx.GetString(Resource.String.ChangeLog_0_9_9c),
ctx.GetString(Resource.String.ChangeLog_0_9_9), ctx.GetString(Resource.String.ChangeLog_0_9_9),

View File

@ -62,11 +62,19 @@ namespace keepass2android
yield return new Reminder yield return new Reminder
{ {
From = new DateTime(2016, 09, 17), From = new DateTime(2016, 09, 17),
To = new DateTime(2016, 10, 04), To = new DateTime(2016, 09, 26),
Key = "DonationOktoberfest2016" Key = "DonationOktoberfest2016"
,ResourceToShow = Resource.Layout.donate ,ResourceToShow = Resource.Layout.donate
}; };
yield return new Reminder yield return new Reminder
{
From = new DateTime(2016, 09, 26),
To = new DateTime(2016, 10, 04),
Key = "DonationOktoberfest2016-2"
,
ResourceToShow = Resource.Layout.donate
};
yield return new Reminder
{ {
From = new DateTime(2017, 09, 16), From = new DateTime(2017, 09, 16),
To = new DateTime(2017, 09, 25), To = new DateTime(2017, 09, 25),

View File

@ -118,7 +118,16 @@ namespace keepass2android
FindViewById(Resource.Id.radio_buttons).Visibility = ViewStates.Gone; FindViewById(Resource.Id.radio_buttons).Visibility = ViewStates.Gone;
FindViewById(Resource.Id.fingerprint_auth_container).Visibility = ViewStates.Gone; FindViewById(Resource.Id.fingerprint_auth_container).Visibility = ViewStates.Gone;
FindViewById<CheckBox>(Resource.Id.show_keyboard_while_fingerprint).Checked =
Util.GetShowKeyboardDuringFingerprintUnlock(this);
FindViewById<CheckBox>(Resource.Id.show_keyboard_while_fingerprint).CheckedChange += (sender, args) =>
{
PreferenceManager.GetDefaultSharedPreferences(this)
.Edit()
.PutBoolean(GetString(Resource.String.ShowKeyboardWhileFingerprint_key), args.IsChecked)
.Commit();
};
if ((int)Build.VERSION.SdkInt >= 23) if ((int)Build.VERSION.SdkInt >= 23)
RequestPermissions(new[] {Manifest.Permission.UseFingerprint}, FingerprintPermissionRequestCode); RequestPermissions(new[] {Manifest.Permission.UseFingerprint}, FingerprintPermissionRequestCode);
else else
@ -127,6 +136,17 @@ namespace keepass2android
} }
UpdateKeyboardCheckboxVisibility();
}
private void UpdateKeyboardCheckboxVisibility()
{
FindViewById(Resource.Id.show_keyboard_while_fingerprint).Visibility = (_unlockMode == FingerprintUnlockMode.Disabled) ||
(_samsungFingerprint != null)
? ViewStates.Gone
: ViewStates.Visible;
} }
private bool TrySetupSamsung() private bool TrySetupSamsung()
@ -205,6 +225,7 @@ namespace keepass2android
//seems like not all Samsung Devices (e.g. Note 4) don't support the Android 6 fingerprint API //seems like not all Samsung Devices (e.g. Note 4) don't support the Android 6 fingerprint API
if (!TrySetupSamsung()) if (!TrySetupSamsung())
SetError(Resource.String.fingerprint_hardware_error); SetError(Resource.String.fingerprint_hardware_error);
UpdateKeyboardCheckboxVisibility();
return; return;
} }
if (!fpModule.FingerprintManager.HasEnrolledFingerprints) if (!fpModule.FingerprintManager.HasEnrolledFingerprints)
@ -213,6 +234,7 @@ namespace keepass2android
return; return;
} }
ShowRadioButtons(); ShowRadioButtons();
UpdateKeyboardCheckboxVisibility();
} }
} }
@ -229,9 +251,12 @@ namespace keepass2android
if (oldMode == newMode) if (oldMode == newMode)
return; return;
if (_samsungFingerprint != null) if (_samsungFingerprint != null)
{ {
_unlockMode = newMode; _unlockMode = newMode;
UpdateKeyboardCheckboxVisibility();
ISharedPreferencesEditor edit = PreferenceManager.GetDefaultSharedPreferences(this).Edit(); ISharedPreferencesEditor edit = PreferenceManager.GetDefaultSharedPreferences(this).Edit();
edit.PutString(App.Kp2a.GetDb().CurrentFingerprintModePrefKey, _unlockMode.ToString()); edit.PutString(App.Kp2a.GetDb().CurrentFingerprintModePrefKey, _unlockMode.ToString());
edit.Commit(); edit.Commit();
@ -241,14 +266,17 @@ namespace keepass2android
if (newMode == FingerprintUnlockMode.Disabled) if (newMode == FingerprintUnlockMode.Disabled)
{ {
_unlockMode = newMode; _unlockMode = newMode;
UpdateKeyboardCheckboxVisibility();
StoreUnlockMode(); StoreUnlockMode();
return; return;
} }
_desiredUnlockMode = newMode; _desiredUnlockMode = newMode;
FindViewById(Resource.Id.radio_buttons).Visibility = ViewStates.Gone; FindViewById(Resource.Id.radio_buttons).Visibility = ViewStates.Gone;
FindViewById(Resource.Id.fingerprint_auth_container).Visibility = ViewStates.Visible; FindViewById(Resource.Id.show_keyboard_while_fingerprint).Visibility = ViewStates.Gone;
FindViewById(Resource.Id.fingerprint_auth_container).Visibility = ViewStates.Visible;
_enc = new FingerprintEncryption(new FingerprintModule(this), CurrentPreferenceKey); _enc = new FingerprintEncryption(new FingerprintModule(this), CurrentPreferenceKey);
try try
{ {
@ -289,6 +317,8 @@ namespace keepass2android
FindViewById(Resource.Id.fingerprint_auth_container).Visibility = ViewStates.Gone; FindViewById(Resource.Id.fingerprint_auth_container).Visibility = ViewStates.Gone;
StoreUnlockMode(); StoreUnlockMode();
UpdateKeyboardCheckboxVisibility();
}, SUCCESS_DELAY_MILLIS); }, SUCCESS_DELAY_MILLIS);

View File

@ -1733,12 +1733,7 @@ namespace keepass2android
} }
EditText pwd = FindViewById<EditText>(Resource.Id.password_edit);
pwd.PostDelayed(() =>
{
InputMethodManager keyboard = (InputMethodManager)GetSystemService(Context.InputMethodService);
keyboard.ShowSoftInput(pwd, 0);
}, 50);
View killButton = FindViewById(Resource.Id.kill_app); View killButton = FindViewById(Resource.Id.kill_app);
if (PreferenceManager.GetDefaultSharedPreferences(this) if (PreferenceManager.GetDefaultSharedPreferences(this)
@ -1811,19 +1806,33 @@ namespace keepass2android
} }
} }
bool showKeyboard = (Util.GetShowKeyboardDuringFingerprintUnlock(this));
if (_fingerprintPermissionGranted) if (_fingerprintPermissionGranted)
{ {
InitFingerprintUnlock(); if (!InitFingerprintUnlock())
showKeyboard = true;
} }
else else
{ {
FindViewById<ImageButton>(Resource.Id.fingerprintbtn).Visibility = ViewStates.Gone; FindViewById<ImageButton>(Resource.Id.fingerprintbtn).Visibility = ViewStates.Gone;
showKeyboard = true;
} }
EditText pwd = (EditText)FindViewById(Resource.Id.password_edit);
pwd.PostDelayed(() =>
{
InputMethodManager keyboard = (InputMethodManager)GetSystemService(Context.InputMethodService);
if (showKeyboard)
keyboard.ShowSoftInput(pwd, 0);
else
keyboard.HideSoftInputFromWindow(pwd.WindowToken, HideSoftInputFlags.ImplicitOnly);
}, 50);
} }
private void InitFingerprintUnlock() private bool InitFingerprintUnlock()
{ {
var btn = FindViewById<ImageButton>(Resource.Id.fingerprintbtn); var btn = FindViewById<ImageButton>(Resource.Id.fingerprintbtn);
try try
@ -1834,7 +1843,7 @@ namespace keepass2android
if (um != FingerprintUnlockMode.FullUnlock) if (um != FingerprintUnlockMode.FullUnlock)
{ {
return; return false;
} }
FingerprintModule fpModule = new FingerprintModule(this); FingerprintModule fpModule = new FingerprintModule(this);
@ -1847,6 +1856,7 @@ namespace keepass2android
{ {
btn.SetImageResource(Resource.Drawable.ic_fp_40px); btn.SetImageResource(Resource.Drawable.ic_fp_40px);
_fingerprintDec.StartListening(new FingerprintAuthCallbackAdapter(this, this)); _fingerprintDec.StartListening(new FingerprintAuthCallbackAdapter(this, this));
return true;
} }
else else
{ {
@ -1856,6 +1866,7 @@ namespace keepass2android
_fingerprintDec = null; _fingerprintDec = null;
ClearFingerprintUnlockData(); ClearFingerprintUnlockData();
return false;
} }
} }
catch (Exception e) catch (Exception e)
@ -1864,6 +1875,7 @@ namespace keepass2android
btn.Tag = "Error initializing Fingerprint Unlock: " + e; btn.Tag = "Error initializing Fingerprint Unlock: " + e;
_fingerprintDec = null; _fingerprintDec = null;
return false;
} }

View File

@ -213,7 +213,7 @@ namespace keepass2android
} }
private void InitFingerprintUnlock() private bool InitFingerprintUnlock()
{ {
Kp2aLog.Log("InitFingerprintUnlock"); Kp2aLog.Log("InitFingerprintUnlock");
var btn = FindViewById<ImageButton>(Resource.Id.fingerprintbtn); var btn = FindViewById<ImageButton>(Resource.Id.fingerprintbtn);
@ -225,7 +225,7 @@ namespace keepass2android
if (um == FingerprintUnlockMode.Disabled) if (um == FingerprintUnlockMode.Disabled)
{ {
return; return false;
} }
if (_fingerprintPermissionGranted) if (_fingerprintPermissionGranted)
@ -254,7 +254,7 @@ namespace keepass2android
{ {
Kp2aLog.Log("trying Samsung Fingerprint API...failed."); Kp2aLog.Log("trying Samsung Fingerprint API...failed.");
FindViewById<ImageButton>(Resource.Id.fingerprintbtn).Visibility = ViewStates.Gone; FindViewById<ImageButton>(Resource.Id.fingerprintbtn).Visibility = ViewStates.Gone;
return; return false;
} }
} }
btn.Tag = GetString(Resource.String.fingerprint_unlock_hint); btn.Tag = GetString(Resource.String.fingerprint_unlock_hint);
@ -264,6 +264,7 @@ namespace keepass2android
Kp2aLog.Log("successfully initialized fingerprint."); Kp2aLog.Log("successfully initialized fingerprint.");
btn.SetImageResource(Resource.Drawable.ic_fp_40px); btn.SetImageResource(Resource.Drawable.ic_fp_40px);
_fingerprintIdentifier.StartListening(this, this); _fingerprintIdentifier.StartListening(this, this);
return true;
} }
else else
{ {
@ -284,7 +285,7 @@ namespace keepass2android
_fingerprintIdentifier = null; _fingerprintIdentifier = null;
} }
return false;
} }
@ -335,19 +336,29 @@ namespace keepass2android
CheckIfUnloaded(); CheckIfUnloaded();
bool showKeyboard = ((!InitFingerprintUnlock()) || (Util.GetShowKeyboardDuringFingerprintUnlock(this)));
EditText pwd = (EditText)FindViewById(Resource.Id.QuickUnlock_password); EditText pwd = (EditText)FindViewById(Resource.Id.QuickUnlock_password);
pwd.PostDelayed(() => pwd.PostDelayed(() =>
{ {
InputMethodManager keyboard = (InputMethodManager)GetSystemService(Context.InputMethodService); InputMethodManager keyboard = (InputMethodManager)GetSystemService(Context.InputMethodService);
if (showKeyboard)
keyboard.ShowSoftInput(pwd, 0); keyboard.ShowSoftInput(pwd, 0);
else
keyboard.HideSoftInputFromWindow(pwd.WindowToken, HideSoftInputFlags.ImplicitOnly);
}, 50); }, 50);
InitFingerprintUnlock();
} }
protected override void OnPause() protected override void OnPause()
{ {
base.OnPause(); base.OnPause();

View File

@ -67,6 +67,12 @@
app:title_text="@string/enable_fingerprint_unlock" app:title_text="@string/enable_fingerprint_unlock"
android:background="?android:attr/selectableItemBackground" /> android:background="?android:attr/selectableItemBackground" />
</LinearLayout> </LinearLayout>
<CheckBox
android:id="@+id/show_keyboard_while_fingerprint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:text="@string/ShowKeyboardDuringFingerprintAuth" />
</LinearLayout> </LinearLayout>
<RelativeLayout <RelativeLayout
android:id="@+id/fingerprint_auth_container" android:id="@+id/fingerprint_auth_container"

View File

@ -78,6 +78,7 @@
<bool name="ShowUsernameInList_default">true</bool> <bool name="ShowUsernameInList_default">true</bool>
<bool name="ShowGroupnameInSearchResult_default">true</bool> <bool name="ShowGroupnameInSearchResult_default">true</bool>
<string name="ViewDatabaseSecure_key">ViewDatabaseSecure</string> <string name="ViewDatabaseSecure_key">ViewDatabaseSecure</string>
<string name="ShowKeyboardWhileFingerprint_key">ShowKeyboardWhileFingerprint_key</string>
<bool name="RememberRecentFiles_default">true</bool> <bool name="RememberRecentFiles_default">true</bool>
<string name="TrayTotp_SettingsField_key">TrayTotp_SettingsField_key</string> <string name="TrayTotp_SettingsField_key">TrayTotp_SettingsField_key</string>
<string name="TrayTotp_SeedField_key">TrayTotp_SeedField_key</string> <string name="TrayTotp_SeedField_key">TrayTotp_SeedField_key</string>

View File

@ -655,13 +655,20 @@
<string name="ActivateAutoFillService_btnKeyboard">Use built-in keyboard</string> <string name="ActivateAutoFillService_btnKeyboard">Use built-in keyboard</string>
<string name="ActivateAutoFillService_btnAutoFill">Use AutoFill service</string> <string name="ActivateAutoFillService_btnAutoFill">Use AutoFill service</string>
<string name="ActivateAutoFillService_toast">Please enable the Keepass2Android service.</string> <string name="ActivateAutoFillService_toast">Please enable the Keepass2Android service.</string>
<string name="ShowKeyboardDuringFingerprintAuth">Show soft keyboard for password input when fingerprint scan is active.</string>
<string name="ChangeLog_0_9_8c"> <string name="ChangeLog_0_9_8c">
Version 0.9.8c\n Version 0.9.8c\n
* Fix for SSL vulnerability in Microsoft Live SDK (used when accessing files via OneDrive)\n * Fix for SSL vulnerability in Microsoft Live SDK (used when accessing files via OneDrive)\n
* Bug fix: Previous release contained two input methods (one crashing)\n * Bug fix: Previous release contained two input methods (one crashing)\n
</string> </string>
<string name="ChangeLog_1_0_0e">
Version 1.0.0e\n
* fix for Fingerprint Unlock on older Samsung devices with Android 6\n
* add native support for x86 devices\n
* allow to hide softkeyboard during fingerprint scan\n
* build system update
</string>
<string name="ChangeLog_1_0_0"> <string name="ChangeLog_1_0_0">
Version 1.0.0\n Version 1.0.0\n
* Fingerprint Unlock (requires Android 6.0+ or a Samsung device)\n * Fingerprint Unlock (requires Android 6.0+ or a Samsung device)\n

View File

@ -490,6 +490,13 @@ namespace keepass2android
} }
} }
public static bool GetShowKeyboardDuringFingerprintUnlock(Context ctx)
{
return (PreferenceManager.GetDefaultSharedPreferences(ctx).GetBoolean(
ctx.GetString(Resource.String.ShowKeyboardWhileFingerprint_key), true));
}
public static void MoveBottomBarButtons(int btn1Id, int btn2Id, int bottomBarId, Activity context) public static void MoveBottomBarButtons(int btn1Id, int btn2Id, int bottomBarId, Activity context)
{ {

View File

@ -48,7 +48,7 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<AndroidUseSharedRuntime>False</AndroidUseSharedRuntime> <AndroidUseSharedRuntime>False</AndroidUseSharedRuntime>
<ConsolePause>False</ConsolePause> <ConsolePause>False</ConsolePause>
<AndroidSupportedAbis>armeabi,armeabi-v7a,x86</AndroidSupportedAbis> <AndroidSupportedAbis>armeabi,armeabi-v7a,x86,x86_64</AndroidSupportedAbis>
<CustomCommands> <CustomCommands>
<CustomCommands> <CustomCommands>
<Command type="BeforeBuild" command="UseManifestNet.bat" /> <Command type="BeforeBuild" command="UseManifestNet.bat" />
@ -58,18 +58,16 @@
<DefineConstants>RELEASE</DefineConstants> <DefineConstants>RELEASE</DefineConstants>
<AndroidLinkSkip>System.Core%3b</AndroidLinkSkip> <AndroidLinkSkip>System.Core%3b</AndroidLinkSkip>
<EmbedAssembliesIntoApk>True</EmbedAssembliesIntoApk> <EmbedAssembliesIntoApk>True</EmbedAssembliesIntoApk>
<AndroidStoreUncompressedFileExtensions>
</AndroidStoreUncompressedFileExtensions>
<AndroidLinkMode>SdkOnly</AndroidLinkMode> <AndroidLinkMode>SdkOnly</AndroidLinkMode>
<BundleAssemblies>False</BundleAssemblies> <BundleAssemblies>False</BundleAssemblies>
<AndroidCreatePackagePerAbi>False</AndroidCreatePackagePerAbi> <AndroidCreatePackagePerAbi>False</AndroidCreatePackagePerAbi>
<MandroidI18n />
<Debugger>Xamarin</Debugger> <Debugger>Xamarin</Debugger>
<AotAssemblies>False</AotAssemblies> <AotAssemblies>False</AotAssemblies>
<EnableLLVM>False</EnableLLVM> <EnableLLVM>False</EnableLLVM>
<AndroidEnableMultiDex>False</AndroidEnableMultiDex> <AndroidEnableMultiDex>False</AndroidEnableMultiDex>
<EnableProguard>False</EnableProguard> <EnableProguard>False</EnableProguard>
<DevInstrumentationEnabled>False</DevInstrumentationEnabled> <DevInstrumentationEnabled>False</DevInstrumentationEnabled>
<DebugSymbols>False</DebugSymbols>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ReleaseNoNet|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ReleaseNoNet|AnyCPU' ">
<DebugType>none</DebugType> <DebugType>none</DebugType>
@ -91,6 +89,7 @@
</AndroidStoreUncompressedFileExtensions> </AndroidStoreUncompressedFileExtensions>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Java.Interop" />
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />