diff --git a/app/src/main/java/com/kunzisoft/keepass/autofill/AutofillHelper.kt b/app/src/main/java/com/kunzisoft/keepass/autofill/AutofillHelper.kt
index c83af633c..0ae33b401 100644
--- a/app/src/main/java/com/kunzisoft/keepass/autofill/AutofillHelper.kt
+++ b/app/src/main/java/com/kunzisoft/keepass/autofill/AutofillHelper.kt
@@ -71,6 +71,23 @@ object AutofillHelper {
return ""
}
+ internal fun addHeader(responseBuilder: FillResponse.Builder,
+ packageName: String,
+ webDomain: String?,
+ applicationId: String?) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
+ if (webDomain != null) {
+ responseBuilder.setHeader(RemoteViews(packageName, R.layout.item_autofill_web_domain).apply {
+ setTextViewText(R.id.autofill_web_domain_text, webDomain)
+ })
+ } else if (applicationId != null) {
+ responseBuilder.setHeader(RemoteViews(packageName, R.layout.item_autofill_app_id).apply {
+ setTextViewText(R.id.autofill_app_id_text, applicationId)
+ })
+ }
+ }
+ }
+
internal fun buildDataset(context: Context,
entryInfo: EntryInfo,
struct: StructureParser.Result): Dataset? {
@@ -195,11 +212,11 @@ object AutofillHelper {
private fun newRemoteViews(context: Context,
remoteViewsText: String,
remoteViewsIcon: IconImage? = null): RemoteViews {
- val presentation = RemoteViews(context.packageName, R.layout.item_autofill_service)
- presentation.setTextViewText(R.id.text, remoteViewsText)
+ val presentation = RemoteViews(context.packageName, R.layout.item_autofill_entry)
+ presentation.setTextViewText(R.id.autofill_entry_text, remoteViewsText)
if (remoteViewsIcon != null) {
presentation.assignDatabaseIcon(context,
- R.id.icon,
+ R.id.autofill_entry_icon,
Database.getInstance().drawFactory,
remoteViewsIcon,
ContextCompat.getColor(context, R.color.green))
diff --git a/app/src/main/java/com/kunzisoft/keepass/autofill/KeeAutofillService.kt b/app/src/main/java/com/kunzisoft/keepass/autofill/KeeAutofillService.kt
index 37b877384..04007d902 100644
--- a/app/src/main/java/com/kunzisoft/keepass/autofill/KeeAutofillService.kt
+++ b/app/src/main/java/com/kunzisoft/keepass/autofill/KeeAutofillService.kt
@@ -53,6 +53,8 @@ class KeeAutofillService : AutofillService() {
searchInfo,
{ items ->
val responseBuilder = FillResponse.Builder()
+ AutofillHelper.addHeader(responseBuilder, packageName,
+ parseResult.domain, parseResult.applicationId)
items.forEach {
responseBuilder.addDataset(AutofillHelper.buildDataset(this, it, parseResult))
}
@@ -79,10 +81,19 @@ class KeeAutofillService : AutofillService() {
// to generate Response.
val sender = AutofillLauncherActivity.getAuthIntentSenderForResponse(this,
searchInfo)
- val presentation = RemoteViews(packageName, R.layout.item_autofill_service_unlock)
-
val responseBuilder = FillResponse.Builder()
- responseBuilder.setAuthentication(autofillIds, sender, presentation)
+ val remoteViewsUnlock: RemoteViews = if (!parseResult.domain.isNullOrEmpty()) {
+ RemoteViews(packageName, R.layout.item_autofill_unlock_web_domain).apply {
+ setTextViewText(R.id.autofill_web_domain_text, parseResult.domain)
+ }
+ } else if (!parseResult.applicationId.isNullOrEmpty()) {
+ RemoteViews(packageName, R.layout.item_autofill_unlock_app_id).apply {
+ setTextViewText(R.id.autofill_app_id_text, parseResult.applicationId)
+ }
+ } else {
+ RemoteViews(packageName, R.layout.item_autofill_unlock)
+ }
+ responseBuilder.setAuthentication(autofillIds, sender, remoteViewsUnlock)
callback.onSuccess(responseBuilder.build())
}
}
diff --git a/app/src/main/res/drawable/ic_apps_white_24dp.xml b/app/src/main/res/drawable/ic_apps_white_24dp.xml
new file mode 100644
index 000000000..373f7752b
--- /dev/null
+++ b/app/src/main/res/drawable/ic_apps_white_24dp.xml
@@ -0,0 +1,5 @@
+
+
+
diff --git a/app/src/main/res/drawable/ic_web_white_24dp.xml b/app/src/main/res/drawable/ic_web_white_24dp.xml
new file mode 100644
index 000000000..880e42770
--- /dev/null
+++ b/app/src/main/res/drawable/ic_web_white_24dp.xml
@@ -0,0 +1,5 @@
+
+
+
diff --git a/app/src/main/res/layout/item_autofill_app_id.xml b/app/src/main/res/layout/item_autofill_app_id.xml
new file mode 100644
index 000000000..5358ef3dd
--- /dev/null
+++ b/app/src/main/res/layout/item_autofill_app_id.xml
@@ -0,0 +1,43 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/item_autofill_service.xml b/app/src/main/res/layout/item_autofill_entry.xml
similarity index 95%
rename from app/src/main/res/layout/item_autofill_service.xml
rename to app/src/main/res/layout/item_autofill_entry.xml
index 14e5c95c0..a7202488b 100644
--- a/app/src/main/res/layout/item_autofill_service.xml
+++ b/app/src/main/res/layout/item_autofill_entry.xml
@@ -22,7 +22,7 @@
android:orientation="horizontal">
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/layout/item_autofill_unlock_app_id.xml b/app/src/main/res/layout/item_autofill_unlock_app_id.xml
new file mode 100644
index 000000000..b9fbfad3b
--- /dev/null
+++ b/app/src/main/res/layout/item_autofill_unlock_app_id.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/item_autofill_unlock_web_domain.xml b/app/src/main/res/layout/item_autofill_unlock_web_domain.xml
new file mode 100644
index 000000000..973baa9bf
--- /dev/null
+++ b/app/src/main/res/layout/item_autofill_unlock_web_domain.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/item_autofill_web_domain.xml b/app/src/main/res/layout/item_autofill_web_domain.xml
new file mode 100644
index 000000000..4258b4607
--- /dev/null
+++ b/app/src/main/res/layout/item_autofill_web_domain.xml
@@ -0,0 +1,43 @@
+
+
+
+
+
\ No newline at end of file