Skip to content

Update Autopull component #49

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/feature-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ jobs:
- name: Android Lint
run: ./gradlew lintDebug
- name: Upload Android Lint Report
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: android-lint-report
path: build/reports/android-lint.html
# step 4
- name: Run Unit Tests
run: ./gradlew testDebugUnitTest
- name: Upload Unit Test Reports
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
if: always()
with:
name: unit-test-report
Expand Down Expand Up @@ -70,7 +70,7 @@ jobs:
# step 2
- name: Upload results
if: always()
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: instrumentation-test-results
path: build/androidTest-results
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": ["test@mail.com", "123456"] },
{ "description": "Has more then one order history.", "values": ["meal@mail.com", "123456"] },
{ "description": "Has more then one order history.", "values": ["dev@mail.com", "123456"] },
{ "description": "Has more then one order history.", "values": ["tools@mail.com", "123456"] }
{ "description": "Temporary test user.", "values": ["test@mail.com", "123456"] },
{ "description": "Temporary tool user.", "values": ["tools@mail.com", "123456"] }
],
"Test Users": [
{ "description": "Has more then one order history.", "values": ["test@mail.com", "123456"] },
{ "description": "Has more then one order history.", "values": ["meal@mail.com", "123456"] },
{ "description": "Has more then one order history.", "values": ["dev@mail.com", "123456"] },
{ "description": "Has more then one order history.", "values": ["tools@mail.com", "123456"] }
{ "description": "Test regular user.", "values": ["test@mail.com", "123456"] },
{ "description": "Test tool user.", "values": ["tools@mail.com", "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
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import com.trendyol.android.devtools.analyticslogger.internal.data.model.EventEn
@Dao
internal interface EventDao {

@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")
@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",
)
suspend fun find(query: String, platform: String, limit: Int, offset: Int): List<EventEntity>

@Insert
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ internal class EventManagerImpl(
override suspend fun find(query: String?, platform: String, page: Int, pageSize: Int): List<Event> {
val events = eventRepository.find(
query = "%${query.orEmpty()}%",
platform = "%${platform}%",
platform = "%$platform%",
limit = PAGE_LIMIT,
offset = calculateOffset(page),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import androidx.recyclerview.widget.RecyclerView
import com.trendyol.android.devtools.analyticslogger.databinding.AnalyticsLoggerItemEventPlatformBinding
import com.trendyol.android.devtools.analyticslogger.internal.factory.ColorFactory

class EventPlatformAdapter(
): RecyclerView.Adapter<EventPlatformAdapter.EventPlatformViewHolder>() {
class EventPlatformAdapter() : RecyclerView.Adapter<EventPlatformAdapter.EventPlatformViewHolder>() {

private val platforms: MutableList<String> = mutableListOf()
var onItemSelected: ((platform: String) -> Unit)? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ internal class EventsFragment : Fragment() {

private fun observeData() {
with(viewLifecycleOwner.lifecycleScope) {

launch {
viewModel.eventsFlow.collectLatest {
eventAdapter?.submitData(it)
Expand All @@ -84,7 +83,6 @@ internal class EventsFragment : Fragment() {
eventPlatformAdapter.submitData(it)
}
}

}
}

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
Loading