suggest to enable fingerprint if hardware is detected but fingerprint unlock not configured, closes #426 and closes #355

This commit is contained in:
Philipp Crocoll
2018-07-12 06:44:02 +02:00
parent 22ccda8d34
commit 778775055f
3 changed files with 110 additions and 1 deletions

View File

@@ -53,6 +53,7 @@ namespace keepass2android
{ Resource.Id.cancel_insert_element, 20 },
{ Resource.Id.insert_element, 20 },
//only use the same id if elements can be shown simultaneously!
{ Resource.Id.fingerprint_infotext, 12 },
{ Resource.Id.autofill_infotext, 11 },
{ Resource.Id.notification_info_android8_infotext, 10 },
{ Resource.Id.infotext, 9 },
@@ -239,6 +240,7 @@ namespace keepass2android
AppTask.StartInGroupActivity(this);
AppTask.SetupGroupBaseActivityButtons(this);
UpdateFingerprintInfo();
UpdateAutofillInfo();
UpdateAndroid8NotificationInfo();
UpdateInfotexts();
@@ -441,7 +443,33 @@ namespace keepass2android
}
};
}
if (FindViewById(Resource.Id.info_dont_show_fingerprint_again) != null)
{
FindViewById(Resource.Id.info_dont_show_fingerprint_again).Click += (sender, args) =>
{
_prefs.Edit().PutBoolean(fingerprintinfohidden_prefskey, true).Commit();
UpdateFingerprintInfo();
};
}
if (FindViewById(Resource.Id.hide_fingerprint_info) != null)
{
FindViewById(Resource.Id.hide_fingerprint_info).Click += (sender, args) =>
{
_prefs.Edit().PutBoolean(fingerprintinfohidden_prefskey + App.Kp2a.GetDb().CurrentFingerprintPrefKey, true).Commit();
UpdateFingerprintInfo();
};
}
if (FindViewById(Resource.Id.enable_fingerprint) != null)
{
FindViewById(Resource.Id.enable_fingerprint).Click += (sender, args) =>
{
StartActivity(typeof(FingerprintSetupActivity));
};
}
if (FindViewById(Resource.Id.info_dont_show_autofill_again) != null)
{
@@ -565,6 +593,7 @@ namespace keepass2android
}
const string autofillservicewasenabled_prefskey = "AutofillServiceWasEnabled";
const string fingerprintinfohidden_prefskey = "fingerprintinfohidden_prefskey";
private void UpdateAutofillInfo()
{
@@ -594,6 +623,33 @@ namespace keepass2android
UpdateBottomBarElementVisibility(Resource.Id.autofill_infotext, canShowAutofillInfo);
}
private void UpdateFingerprintInfo()
{
bool canShowFingerprintInfo = false;
bool disabledForDatabase = _prefs.GetBoolean(fingerprintinfohidden_prefskey + App.Kp2a.GetDb().CurrentFingerprintPrefKey, false);
bool disabledForAll = _prefs.GetBoolean(fingerprintinfohidden_prefskey, false);
if (!disabledForAll && !disabledForDatabase)
{
FingerprintModule fpModule = new FingerprintModule(this);
if (fpModule.FingerprintManager.IsHardwareDetected)
{
FingerprintUnlockMode um;
Enum.TryParse(_prefs.GetString(Database.GetFingerprintModePrefKey(App.Kp2a.GetDb().Ioc), ""), out um);
canShowFingerprintInfo = um == FingerprintUnlockMode.Disabled;
}
}
if (canShowFingerprintInfo)
{
RegisterInfoTextDisplay("FingerprintSuggestion"); //this ensures that we don't show the general info texts too soon
}
UpdateBottomBarElementVisibility(Resource.Id.fingerprint_infotext, canShowFingerprintInfo);
}
protected void UpdateBottomBarElementVisibility(int resourceId, bool canShow)
{
if (canShow)

View File

@@ -85,6 +85,57 @@
android:text="@string/dont_show_again"
style="@style/BottomBarButton" />
</LinearLayout>
<LinearLayout
android:id="@+id/fingerprint_infotext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:orientation="vertical">
<TextView android:id="@+id/myinfotext" android:text="@string/enable_fingerprint_hint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:layout_margin="6dp"
android:layout_marginBottom="2dp"
/>
<RelativeLayout
android:id="@+id/fingerprint_buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:baselineAligned="false">
<Button
android:id="@+id/enable_fingerprint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:paddingTop="4dp"
android:text="@string/yes"
style="@style/BottomBarButton" />
<Button
android:id="@+id/hide_fingerprint_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:paddingTop="4dp"
android:text="@string/no"
style="@style/BottomBarButton" />
</RelativeLayout>
<Button
android:id="@+id/info_dont_show_fingerprint_again"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="4dp"
android:text="@string/dont_show_again"
style="@style/BottomBarButton" />
</LinearLayout>
<LinearLayout
android:id="@+id/notification_info_android8_infotext"
android:layout_width="match_parent"

View File

@@ -1132,6 +1132,8 @@ Initial public release
<string name="autofill_sign_in_prompt">Fill with Keepass2Android</string>
<string name="invalid_link_association">Could not associate web domain %1$s with app %2$s</string>
<string name="enable_fingerprint_hint">Keepass2Android has detected fingerprint hardware. Do you want to enable fingerprint unlock for this database?</string>
<string name="understand">I understand</string>
<string name="dont_show_again">Do not show again</string>