Skip to content

Commit

Permalink
- Update README.md for autofill usage.
Browse files Browse the repository at this point in the history
- 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`.
  • Loading branch information
bilgehankalkan committed Dec 20, 2024
1 parent 91fb7d3 commit cd6ebe7
Show file tree
Hide file tree
Showing 17 changed files with 286 additions and 324 deletions.
64 changes: 46 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,44 +38,72 @@ Autofill data that suitable with inflated form inputs are shown in the selection
</table>

### Usage
```kotlin
AutofillService.Builder(this)
.withFilePath("autofill.json")
.build()
Autofill will automatically started if added as dependency. It checks `autofill.json` file on assets directory of the
project. If you want to disable Autofill to be initialized, you can modify `AndroidManifest.xml` like below on `main` or
desired flavor/variant.

```xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<application>

<provider
android:name="androidx.startup.InitializationProvider"
android:authorities="${applicationId}.androidx-startup"
tools:node="remove">

<meta-data
android:name="com.trendyol.android.devtools.autofillservice.AutofillInitializer"
android:value="androidx.startup" />
</provider>
</application>
</manifest>
```

### Configuration
Configuration Json file can be located in `/debug/assets` folder. You can define autofill data by following this structure.
You should also note that the order of the defined form field resource id's and order of input values must match.
Configuration Json file can be located in `/[variant/flavor or main]/assets` folder. You can define autofill data by
following this structure. You should also note that the order of the defined form field resource id's and order of
input values must match.

```json
{
"forms": [
{
"fields": ["inputEmail", "inputPassword"], // Form input resource id's
"fields": ["inputEmail", "inputPassword"],
"matchAnyField": true,
"categories": {
"Temporary Users": [
{ "description": "Has more then one order history.", "values": ["[email protected]", "123456"] },
{ "description": "Has more then one order history.", "values": ["[email protected]", "123456"] },
{ "description": "Has more then one order history.", "values": ["[email protected]", "123456"] },
{ "description": "Has more then one order history.", "values": ["[email protected]", "123456"] }
{ "description": "Temporary test user.", "values": ["[email protected]", "123456"] },
{ "description": "Temporary tool user.", "values": ["[email protected]", "123456"] }
],
"Test Users": [
{ "description": "Has more then one order history.", "values": ["[email protected]", "123456"] },
{ "description": "Has more then one order history.", "values": ["[email protected]", "123456"] },
{ "description": "Has more then one order history.", "values": ["[email protected]", "123456"] },
{ "description": "Has more then one order history.", "values": ["[email protected]", "123456"] }
{ "description": "Test regular user.", "values": ["[email protected]", "123456"] },
{ "description": "Test tool user.", "values": ["[email protected]", "123456"] }
]
}
}
]
}
```

- `forms` object declares the forms that will be cheched on activity/fragment screen.
- `fields` are input view ids.
- `matchAnyField` is optional flag to enable the feature whether if all `fields` should be exist or not. Default is `false`.
- `categories` declares inputs, you can provide multiple category and multiple input values.

### Setup
```gradle
"com.trendyol.android.devtools:autofill-service:$version"
"com.trendyol.android.devtools:autofill-service-no-op:$version"
Since Autofill not requires any initialization code, all you need to add the dependency on desired variant/flavor like
below.

```kotlin
dependencies {

debugImplementation("com.trendyol.android.devtools:autofill-service:$version")
}
```

![Maven Central](https://img.shields.io/maven-central/v/com.trendyol.android.devtools/autofill-service?color=%2373c248)

## Analytics Logger
Expand Down
1 change: 0 additions & 1 deletion libraries/autofill-service-no-op/.gitignore

This file was deleted.

52 changes: 0 additions & 52 deletions libraries/autofill-service-no-op/build.gradle

This file was deleted.

Empty file.
21 changes: 0 additions & 21 deletions libraries/autofill-service-no-op/proguard-rules.pro

This file was deleted.

This file was deleted.

4 changes: 3 additions & 1 deletion libraries/autofill-service/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,15 @@ android {
jvmTarget = '11'
}
buildFeatures {
buildConfig false
viewBinding true
}
namespace 'com.trendyol.android.devtools.autofillservice'
}

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

dependencies {
implementation "androidx.core:core-ktx:$ktx_version"
implementation "androidx.startup:startup-runtime:1.2.0"
implementation "androidx.appcompat:appcompat:$appcompat_version"
implementation "com.google.android.material:material:$material_version"

Expand Down
16 changes: 16 additions & 0 deletions libraries/autofill-service/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<application>

<provider
android:name="androidx.startup.InitializationProvider"
android:authorities="${applicationId}.androidx-startup"
tools:node="merge">

<meta-data
android:name="com.trendyol.android.devtools.autofillservice.AutofillInitializer"
android:value="androidx.startup" />
</provider>
</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.trendyol.android.devtools.autofillservice

import android.app.Application
import android.content.Context
import androidx.startup.Initializer
import com.trendyol.android.devtools.autofillservice.internal.AutofillProcessor

class AutofillInitializer : Initializer<Unit> {

override fun create(context: Context) {
AutofillProcessor(
application = context.applicationContext as Application,
filePath = "autofill.json"
)
}

override fun dependencies(): MutableList<Class<out Initializer<*>>> = mutableListOf()
}
Loading

0 comments on commit cd6ebe7

Please sign in to comment.