Skip to content

Commit cd6ebe7

Browse files
- Update README.md for autofill usage.
- Remove `autofill-no-op` component. Update Autofill component: - Create `AutofillInitializer` to automatically initialize the library. - Remove AutofillService.Builder and split AutofillProcessor. - Add logs to json read config. - Add `matchAnyField` flag. - Update `autofill` to `0.2.0`.
1 parent 91fb7d3 commit cd6ebe7

File tree

17 files changed

+286
-324
lines changed

17 files changed

+286
-324
lines changed

README.md

Lines changed: 46 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,44 +38,72 @@ Autofill data that suitable with inflated form inputs are shown in the selection
3838
</table>
3939

4040
### Usage
41-
```kotlin
42-
AutofillService.Builder(this)
43-
.withFilePath("autofill.json")
44-
.build()
41+
Autofill will automatically started if added as dependency. It checks `autofill.json` file on assets directory of the
42+
project. If you want to disable Autofill to be initialized, you can modify `AndroidManifest.xml` like below on `main` or
43+
desired flavor/variant.
44+
45+
```xml
46+
<?xml version="1.0" encoding="utf-8"?>
47+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
48+
xmlns:tools="http://schemas.android.com/tools">
49+
50+
<application>
51+
52+
<provider
53+
android:name="androidx.startup.InitializationProvider"
54+
android:authorities="${applicationId}.androidx-startup"
55+
tools:node="remove">
56+
57+
<meta-data
58+
android:name="com.trendyol.android.devtools.autofillservice.AutofillInitializer"
59+
android:value="androidx.startup" />
60+
</provider>
61+
</application>
62+
</manifest>
4563
```
4664

4765
### Configuration
48-
Configuration Json file can be located in `/debug/assets` folder. You can define autofill data by following this structure.
49-
You should also note that the order of the defined form field resource id's and order of input values must match.
66+
Configuration Json file can be located in `/[variant/flavor or main]/assets` folder. You can define autofill data by
67+
following this structure. You should also note that the order of the defined form field resource id's and order of
68+
input values must match.
69+
5070
```json
5171
{
5272
"forms": [
5373
{
54-
"fields": ["inputEmail", "inputPassword"], // Form input resource id's
74+
"fields": ["inputEmail", "inputPassword"],
75+
"matchAnyField": true,
5576
"categories": {
5677
"Temporary Users": [
57-
{ "description": "Has more then one order history.", "values": ["test@mail.com", "123456"] },
58-
{ "description": "Has more then one order history.", "values": ["meal@mail.com", "123456"] },
59-
{ "description": "Has more then one order history.", "values": ["dev@mail.com", "123456"] },
60-
{ "description": "Has more then one order history.", "values": ["tools@mail.com", "123456"] }
78+
{ "description": "Temporary test user.", "values": ["test@mail.com", "123456"] },
79+
{ "description": "Temporary tool user.", "values": ["tools@mail.com", "123456"] }
6180
],
6281
"Test Users": [
63-
{ "description": "Has more then one order history.", "values": ["test@mail.com", "123456"] },
64-
{ "description": "Has more then one order history.", "values": ["meal@mail.com", "123456"] },
65-
{ "description": "Has more then one order history.", "values": ["dev@mail.com", "123456"] },
66-
{ "description": "Has more then one order history.", "values": ["tools@mail.com", "123456"] }
82+
{ "description": "Test regular user.", "values": ["test@mail.com", "123456"] },
83+
{ "description": "Test tool user.", "values": ["tools@mail.com", "123456"] }
6784
]
6885
}
6986
}
7087
]
7188
}
7289
```
7390

91+
- `forms` object declares the forms that will be cheched on activity/fragment screen.
92+
- `fields` are input view ids.
93+
- `matchAnyField` is optional flag to enable the feature whether if all `fields` should be exist or not. Default is `false`.
94+
- `categories` declares inputs, you can provide multiple category and multiple input values.
95+
7496
### Setup
75-
```gradle
76-
"com.trendyol.android.devtools:autofill-service:$version"
77-
"com.trendyol.android.devtools:autofill-service-no-op:$version"
97+
Since Autofill not requires any initialization code, all you need to add the dependency on desired variant/flavor like
98+
below.
99+
100+
```kotlin
101+
dependencies {
102+
103+
debugImplementation("com.trendyol.android.devtools:autofill-service:$version")
104+
}
78105
```
106+
79107
![Maven Central](https://img.shields.io/maven-central/v/com.trendyol.android.devtools/autofill-service?color=%2373c248)
80108

81109
## Analytics Logger

libraries/autofill-service-no-op/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

libraries/autofill-service-no-op/build.gradle

Lines changed: 0 additions & 52 deletions
This file was deleted.

libraries/autofill-service-no-op/consumer-rules.pro

Whitespace-only changes.

libraries/autofill-service-no-op/proguard-rules.pro

Lines changed: 0 additions & 21 deletions
This file was deleted.

libraries/autofill-service-no-op/src/main/java/com/trendyol/android/devtools/autofillservice/AutofillService.kt

Lines changed: 0 additions & 16 deletions
This file was deleted.

libraries/autofill-service/build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,15 @@ android {
3535
jvmTarget = '11'
3636
}
3737
buildFeatures {
38+
buildConfig false
3839
viewBinding true
3940
}
4041
namespace 'com.trendyol.android.devtools.autofillservice'
4142
}
4243

4344
ext {
4445
PUBLISH_GROUP_ID = 'com.trendyol.android.devtools'
45-
PUBLISH_VERSION = '0.1.0'
46+
PUBLISH_VERSION = '0.2.0'
4647
PUBLISH_ARTIFACT_ID = 'autofill-service'
4748
PUBLISH_DESCRIPTION = "Android QA Form Autofill Service"
4849
PUBLISH_URL = "https://github.com/Trendyol/android-dev-tools"
@@ -57,6 +58,7 @@ apply from: "${rootProject.projectDir}/scripts/publish-module.gradle"
5758

5859
dependencies {
5960
implementation "androidx.core:core-ktx:$ktx_version"
61+
implementation "androidx.startup:startup-runtime:1.2.0"
6062
implementation "androidx.appcompat:appcompat:$appcompat_version"
6163
implementation "com.google.android.material:material:$material_version"
6264

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:tools="http://schemas.android.com/tools">
3+
4+
<application>
5+
6+
<provider
7+
android:name="androidx.startup.InitializationProvider"
8+
android:authorities="${applicationId}.androidx-startup"
9+
tools:node="merge">
10+
11+
<meta-data
12+
android:name="com.trendyol.android.devtools.autofillservice.AutofillInitializer"
13+
android:value="androidx.startup" />
14+
</provider>
15+
</application>
16+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.trendyol.android.devtools.autofillservice
2+
3+
import android.app.Application
4+
import android.content.Context
5+
import androidx.startup.Initializer
6+
import com.trendyol.android.devtools.autofillservice.internal.AutofillProcessor
7+
8+
class AutofillInitializer : Initializer<Unit> {
9+
10+
override fun create(context: Context) {
11+
AutofillProcessor(
12+
application = context.applicationContext as Application,
13+
filePath = "autofill.json"
14+
)
15+
}
16+
17+
override fun dependencies(): MutableList<Class<out Initializer<*>>> = mutableListOf()
18+
}

0 commit comments

Comments
 (0)