Skip to content

Commit 02f1a02

Browse files
Merge pull request #49 from Trendyol/feature/autofill-auto-initialize-and-matchAnyField-flag
Update Autopull component
2 parents 91fb7d3 + f37f974 commit 02f1a02

File tree

44 files changed

+316
-411
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+316
-411
lines changed

.github/workflows/feature-branch.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ jobs:
3434
- name: Android Lint
3535
run: ./gradlew lintDebug
3636
- name: Upload Android Lint Report
37-
uses: actions/upload-artifact@v2
37+
uses: actions/upload-artifact@v4
3838
with:
3939
name: android-lint-report
4040
path: build/reports/android-lint.html
4141
# step 4
4242
- name: Run Unit Tests
4343
run: ./gradlew testDebugUnitTest
4444
- name: Upload Unit Test Reports
45-
uses: actions/upload-artifact@v2
45+
uses: actions/upload-artifact@v4
4646
if: always()
4747
with:
4848
name: unit-test-report
@@ -70,7 +70,7 @@ jobs:
7070
# step 2
7171
- name: Upload results
7272
if: always()
73-
uses: actions/upload-artifact@v2
73+
uses: actions/upload-artifact@v4
7474
with:
7575
name: instrumentation-test-results
7676
path: build/androidTest-results

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/analytics-logger/src/main/java/com/trendyol/android/devtools/analyticslogger/internal/data/dao/EventDao.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ import com.trendyol.android.devtools.analyticslogger.internal.data.model.EventEn
88
@Dao
99
internal interface EventDao {
1010

11-
@Query("SELECT * FROM event_entities WHERE (`key` LIKE :query OR value LIKE :query) AND platform LIKE :platform ORDER BY uid DESC LIMIT :limit OFFSET :offset")
11+
@Query(
12+
"SELECT * FROM event_entities " +
13+
"WHERE (`key` LIKE :query OR value LIKE :query) " +
14+
"AND platform LIKE :platform ORDER BY uid DESC LIMIT :limit OFFSET :offset",
15+
)
1216
suspend fun find(query: String, platform: String, limit: Int, offset: Int): List<EventEntity>
1317

1418
@Insert

libraries/analytics-logger/src/main/java/com/trendyol/android/devtools/analyticslogger/internal/domain/manager/EventManagerImpl.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ internal class EventManagerImpl(
1717
override suspend fun find(query: String?, platform: String, page: Int, pageSize: Int): List<Event> {
1818
val events = eventRepository.find(
1919
query = "%${query.orEmpty()}%",
20-
platform = "%${platform}%",
20+
platform = "%$platform%",
2121
limit = PAGE_LIMIT,
2222
offset = calculateOffset(page),
2323
)

libraries/analytics-logger/src/main/java/com/trendyol/android/devtools/analyticslogger/internal/ui/events/EventPlatformAdapter.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ import androidx.recyclerview.widget.RecyclerView
77
import com.trendyol.android.devtools.analyticslogger.databinding.AnalyticsLoggerItemEventPlatformBinding
88
import com.trendyol.android.devtools.analyticslogger.internal.factory.ColorFactory
99

10-
class EventPlatformAdapter(
11-
): RecyclerView.Adapter<EventPlatformAdapter.EventPlatformViewHolder>() {
10+
class EventPlatformAdapter() : RecyclerView.Adapter<EventPlatformAdapter.EventPlatformViewHolder>() {
1211

1312
private val platforms: MutableList<String> = mutableListOf()
1413
var onItemSelected: ((platform: String) -> Unit)? = null

libraries/analytics-logger/src/main/java/com/trendyol/android/devtools/analyticslogger/internal/ui/events/EventsFragment.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ internal class EventsFragment : Fragment() {
7272

7373
private fun observeData() {
7474
with(viewLifecycleOwner.lifecycleScope) {
75-
7675
launch {
7776
viewModel.eventsFlow.collectLatest {
7877
eventAdapter?.submitData(it)
@@ -84,7 +83,6 @@ internal class EventsFragment : Fragment() {
8483
eventPlatformAdapter.submitData(it)
8584
}
8685
}
87-
8886
}
8987
}
9088

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)