fix crashes on Huawei devices when trying to enable autofill
This commit is contained in:
@@ -26,7 +26,8 @@ namespace keepass2android
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(ctx, Android.Resource.Style.ThemeHoloLightDialog));
|
||||
builder.SetTitle(ctx.GetString(Resource.String.ChangeLog_title));
|
||||
List<string> changeLog = new List<string>{
|
||||
ctx.GetString(Resource.String.ChangeLog_1_04),
|
||||
ctx.GetString(Resource.String.ChangeLog_1_04b),
|
||||
ctx.GetString(Resource.String.ChangeLog_1_04),
|
||||
ctx.GetString(Resource.String.ChangeLog_1_03),
|
||||
ctx.GetString(Resource.String.ChangeLog_1_02),
|
||||
#if !NoNet
|
||||
|
||||
@@ -297,7 +297,23 @@ namespace keepass2android
|
||||
{
|
||||
var intent = new Intent(Settings.ActionRequestSetAutofillService);
|
||||
intent.SetData(Android.Net.Uri.Parse("package:" + PackageName));
|
||||
StartActivity(intent);
|
||||
try
|
||||
{
|
||||
StartActivity(intent);
|
||||
}
|
||||
catch (ActivityNotFoundException e)
|
||||
{
|
||||
//this exception was reported by many Huawei users
|
||||
Kp2aLog.LogUnexpectedError(e);
|
||||
new AlertDialog.Builder(this)
|
||||
.SetTitle(Resource.String.autofill_enable)
|
||||
.SetMessage(Resource.String.autofill_enable_failed)
|
||||
.SetPositiveButton(Resource.String.ok, (o, eventArgs) => { })
|
||||
.Show();
|
||||
const string autofillservicewasenabled = "AutofillServiceWasEnabled";
|
||||
_prefs.Edit().PutBoolean(autofillservicewasenabled, true).Commit();
|
||||
UpdateBottomBarElementVisibility(Resource.Id.autofill_infotext, false);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:versionCode="109"
|
||||
android:versionName="1.04"
|
||||
android:versionCode="110"
|
||||
android:versionName="1.04b"
|
||||
package="keepass2android.keepass2android"
|
||||
android:installLocation="auto">
|
||||
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="23" />
|
||||
|
||||
@@ -692,11 +692,18 @@
|
||||
|
||||
|
||||
<string name="ShowKeyboardDuringFingerprintAuth">Show soft keyboard for password input when fingerprint scan is active.</string>
|
||||
|
||||
<string name="ChangeLog_1_04b">
|
||||
Version 1.04b\n
|
||||
* Avoid crash when user tries to enable Autofill on Huawei devices.\n
|
||||
</string>
|
||||
<string name="ChangeLog_1_04">
|
||||
Version 1.04\n
|
||||
* Added Autofill service for Android 8.0 and later.\n
|
||||
* Upgraded libraries, build tools and Target SDK version.\n
|
||||
</string>
|
||||
|
||||
|
||||
|
||||
<string name="ChangeLog_1_03">
|
||||
Version 1.03\n
|
||||
@@ -1042,6 +1049,7 @@ Initial public release
|
||||
|
||||
<string name="autofill_hint">Keepass2Android supports Android\'s Autofill feature but it looks like you haven\'t enabled it yet.</string>
|
||||
<string name="autofill_enable">Enable Autofill</string>
|
||||
<string name="autofill_enable_failed">Sorry, it looks like your device does not support opening the settings from inside the app. Please go manually to the system settings for AutoFill to enable the service.</string>
|
||||
<string name="show_autofill_help">Show Autofill help</string>
|
||||
<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>
|
||||
|
||||
@@ -371,6 +371,32 @@ namespace keepass2android
|
||||
|
||||
UpdateAutofillPref();
|
||||
|
||||
var autofillPref = FindPreference(GetString(Resource.String.AutoFill_prefs_key));
|
||||
if (autofillPref != null)
|
||||
{
|
||||
autofillPref.PreferenceClick += (sender, args) =>
|
||||
{
|
||||
|
||||
var intent = new Intent(Settings.ActionRequestSetAutofillService);
|
||||
intent.SetData(Android.Net.Uri.Parse("package:" + Context.PackageName));
|
||||
try
|
||||
{
|
||||
Context.StartActivity(intent);
|
||||
}
|
||||
catch (ActivityNotFoundException e)
|
||||
{
|
||||
//this exception was reported by many Huawei users
|
||||
Kp2aLog.LogUnexpectedError(e);
|
||||
new AlertDialog.Builder(Context)
|
||||
.SetTitle(Resource.String.autofill_enable)
|
||||
.SetMessage(Resource.String.autofill_enable_failed)
|
||||
.SetPositiveButton(Resource.String.ok, (o, eventArgs) => { })
|
||||
.Show();
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
PrepareNoDonatePreference(Activity, FindPreference(GetString(Resource.String.NoDonateOption_key)));
|
||||
PrepareNoDonationReminderPreference(Activity, ((PreferenceScreen)FindPreference(GetString(Resource.String.display_prefs_key))), FindPreference(GetString(Resource.String.NoDonationReminder_key)));
|
||||
@@ -488,8 +514,11 @@ namespace keepass2android
|
||||
else
|
||||
{
|
||||
autofillPref.Summary = Activity.GetString(Resource.String.not_enabled);
|
||||
autofillPref.Intent = new Intent(Settings.ActionRequestSetAutofillService);
|
||||
autofillPref.Intent.SetData(Android.Net.Uri.Parse("package:" + Activity.PackageName));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -990,7 +1019,9 @@ namespace keepass2android
|
||||
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Activity to configure the application and database settings. The database must be unlocked, and this activity will close if it becomes locked.
|
||||
/// </summary>
|
||||
[Activity(Label = "@string/app_name", Theme = "@style/MyTheme")]
|
||||
|
||||
Reference in New Issue
Block a user