@@ -12,6 +12,7 @@ import android.view.autofill.AutofillValue
12
12
import android.widget.RemoteViews
13
13
import android.widget.Toast
14
14
import androidx.annotation.RequiresApi
15
+ import com.google.android.material.chip.Chip
15
16
import java.util.*
16
17
import kotlin.collections.ArrayList
17
18
@@ -88,19 +89,23 @@ class MyAutofillService : AutofillService() {
88
89
var i = 0
89
90
90
91
for (mail in emails){
91
- if ((mail.contains(" @" )) or (names[i].toLowerCase(Locale .ROOT ).contains(appName.toLowerCase(
92
- Locale .ROOT
93
- )
94
- )) or (appName.toLowerCase(Locale .ROOT ).contains(names[i].toLowerCase(Locale .ROOT )))
95
- ) {
96
- val remoteView = RemoteViews (packageName, R .layout.autofill_suggestion)
97
- remoteView.setTextViewText(R .id.suggestion_item, mail)
98
- dataSets.add(
99
- Dataset .Builder (remoteView).setValue(
100
- emailFields[0 ]?.autofillId!! ,
101
- AutofillValue .forText(mail)
102
- ).build()
103
- )
92
+ names[i].split(" \\ s" .toRegex()).forEach { partName ->
93
+ if ((mail.contains(" @" )) or (partName.toLowerCase(Locale .ROOT ).contains(
94
+ appName.toLowerCase(
95
+ Locale .ROOT
96
+ )
97
+ )) or (appName.toLowerCase(Locale .ROOT )
98
+ .contains(partName.toLowerCase(Locale .ROOT )))
99
+ ) {
100
+ val remoteView = RemoteViews (packageName, R .layout.autofill_suggestion)
101
+ remoteView.setTextViewText(R .id.suggestion_item, mail)
102
+ dataSets.add(
103
+ Dataset .Builder (remoteView).setValue(
104
+ emailFields[0 ]?.autofillId!! ,
105
+ AutofillValue .forText(mail)
106
+ ).build()
107
+ )
108
+ }
104
109
}
105
110
i + = 1
106
111
}
@@ -112,17 +117,20 @@ class MyAutofillService : AutofillService() {
112
117
val remoteView = RemoteViews (packageName, R .layout.autofill_suggestion)
113
118
remoteView.setTextViewText(R .id.suggestion_item, " Random" )
114
119
for (name in names){
115
- if ((name.toLowerCase(Locale .ROOT ).contains(appName.toLowerCase(Locale .ROOT ))) or
116
- (appName.toLowerCase(Locale .ROOT ).contains(name.toLowerCase(Locale .ROOT )))){
117
- val remoteView = RemoteViews (packageName, R .layout.autofill_suggestion)
118
- remoteView.setTextViewText(R .id.suggestion_item, passwords[i])
119
- dataSets.add(Dataset .Builder (remoteView).setValue(
120
- passFields[0 ]?.autofillId!! ,
121
- AutofillValue .forText(passwords[i])
122
- ).build())
120
+ name.split(" \\ s" .toRegex()).forEach { partName ->
121
+ if ((partName.toLowerCase(Locale .ROOT ).contains(appName.toLowerCase(Locale .ROOT ))) or
122
+ (appName.toLowerCase(Locale .ROOT ).contains(partName.toLowerCase(Locale .ROOT )))){
123
+ val remoteView = RemoteViews (packageName, R .layout.autofill_suggestion)
124
+ remoteView.setTextViewText(R .id.suggestion_item, passwords[i])
125
+ dataSets.add(Dataset .Builder (remoteView).setValue(
126
+ passFields[0 ]?.autofillId!! ,
127
+ AutofillValue .forText(passwords[i])
128
+ ).build())
129
+ }
123
130
}
124
131
i + = 1
125
- }
132
+ }
133
+
126
134
}
127
135
128
136
if (dataSets.size != 0 ){
0 commit comments