-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 2e0579f
Showing
107 changed files
with
5,493 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
.idea/* | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild | ||
.cxx | ||
local.properties |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
import org.gradle.configurationcache.extensions.capitalized | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
|
||
plugins { | ||
alias(libs.plugins.android.application) | ||
alias(libs.plugins.jetbrains.kotlin.android) | ||
id("com.google.dagger.hilt.android") | ||
id("com.google.devtools.ksp") | ||
id("kotlin-parcelize") | ||
id("com.google.protobuf") version ("0.9.4") | ||
} | ||
|
||
android { | ||
namespace = "com.adyen.testcards" | ||
compileSdk = 34 | ||
|
||
defaultConfig { | ||
applicationId = "com.adyen.testcards" | ||
minSdk = 26 | ||
targetSdk = 34 | ||
versionCode = 1 | ||
versionName = "1.0" | ||
|
||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
vectorDrawables { | ||
useSupportLibrary = true | ||
} | ||
} | ||
|
||
signingConfigs { | ||
getByName("debug") {} | ||
} | ||
|
||
|
||
buildTypes { | ||
debug { | ||
isMinifyEnabled = false | ||
} | ||
release { | ||
isMinifyEnabled = true | ||
isDebuggable = false | ||
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") | ||
|
||
signingConfig = signingConfigs.getByName("debug") | ||
} | ||
} | ||
|
||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
} | ||
|
||
kotlinOptions { | ||
jvmTarget = "1.8" | ||
} | ||
|
||
buildFeatures { | ||
compose = true | ||
} | ||
|
||
composeOptions { | ||
kotlinCompilerExtensionVersion = "1.5.15" | ||
} | ||
|
||
packaging { | ||
resources { | ||
excludes += "/META-INF/{AL2.0,LGPL2.1}" | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
|
||
implementation(platform(libs.androidx.compose.bom)) | ||
implementation(libs.androidx.activity.compose) | ||
implementation(libs.androidx.appcompat) | ||
implementation(libs.androidx.autofill) | ||
implementation(libs.androidx.core.ktx) | ||
implementation(libs.androidx.datastore) | ||
implementation(libs.androidx.lifecycle.runtime.compose) | ||
implementation(libs.androidx.lifecycle.runtime.ktx) | ||
implementation(libs.androidx.lifecycle.viewmodel.compose) | ||
implementation(libs.androidx.material3) | ||
implementation(libs.androidx.ui) | ||
implementation(libs.androidx.ui.graphics) | ||
implementation(libs.androidx.ui.tooling.preview) | ||
implementation(libs.hilt) | ||
implementation(libs.material) | ||
implementation(libs.protobuf.lite) | ||
implementation(libs.retrofit) | ||
implementation(libs.retrofit.moshi) | ||
|
||
ksp(libs.hiltCompiler) | ||
ksp(libs.moshi.code.gen) | ||
|
||
testImplementation(libs.junit) | ||
|
||
androidTestImplementation(platform(libs.androidx.compose.bom)) | ||
androidTestImplementation(libs.androidx.junit) | ||
androidTestImplementation(libs.androidx.espresso.core) | ||
androidTestImplementation(libs.androidx.ui.test.junit4) | ||
|
||
debugImplementation(libs.androidx.ui.tooling) | ||
debugImplementation(libs.androidx.ui.test.manifest) | ||
} | ||
|
||
protobuf { | ||
protoc { | ||
artifact = "com.google.protobuf:protoc:${libs.versions.protobuf.get()}" | ||
} | ||
|
||
// Generates the java Protobuf-lite code for the Protobufs in this project. See | ||
// https://github.com/google/protobuf-gradle-plugin#customizing-protobuf-compilation | ||
// for more information. | ||
generateProtoTasks { | ||
all().forEach { task -> | ||
task.plugins { | ||
create("java") { | ||
option("lite") | ||
} | ||
} | ||
|
||
} | ||
} | ||
} | ||
|
||
androidComponents { | ||
onVariants(selector().all()) { variant -> | ||
afterEvaluate { | ||
val capName = variant.name.capitalized() | ||
tasks.getByName<KotlinCompile>("ksp${capName}Kotlin") { | ||
setSource(tasks.getByName("generate${capName}Proto").outputs) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile | ||
-keep class com.adyen.testcards.data.StoredFavorites { *; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
|
||
<application | ||
android:name=".App" | ||
android:allowBackup="true" | ||
android:dataExtractionRules="@xml/data_extraction_rules" | ||
android:enableOnBackInvokedCallback="true" | ||
android:fullBackupContent="@xml/backup_rules" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/Theme.Adyen" | ||
tools:targetApi="31"> | ||
|
||
<activity | ||
android:name=".main.MainActivity" | ||
android:exported="true" | ||
android:theme="@style/Theme.Adyen"> | ||
|
||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
|
||
</activity> | ||
|
||
<activity | ||
android:name=".autofill.AutofillActivity" | ||
android:excludeFromRecents="true" | ||
android:exported="false" | ||
android:launchMode="singleTop" | ||
android:theme="@style/Theme.Adyen.Translucent" /> | ||
|
||
<service | ||
android:name=".autofill.AdyenTestCardsAutofillService" | ||
android:exported="true" | ||
android:label="Adyen Test Cards" | ||
android:permission="android.permission.BIND_AUTOFILL_SERVICE" | ||
tools:targetApi="r"> | ||
|
||
<meta-data | ||
android:name="android.autofill" | ||
android:resource="@xml/test_card_autofill_service_configuration" /> | ||
|
||
<intent-filter> | ||
<action android:name="android.service.autofill.AutofillService" /> | ||
</intent-filter> | ||
|
||
</service> | ||
</application> | ||
|
||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[ | ||
{ | ||
"virtualPaymentAddress": "testvpa@icici" | ||
}, | ||
{ | ||
"virtualPaymentAddress": "billdesk@upi" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
[ | ||
{ | ||
"username": "[email protected]", | ||
"password": "111111", | ||
"type": "Alipay" | ||
}, | ||
{ | ||
"username": "[email protected]", | ||
"password": "a111111", | ||
"type": "Alipay HK" | ||
}, | ||
{ | ||
"username": "u83646180", | ||
"password": "rlf446", | ||
"type": "Pay by bank" | ||
}, | ||
{ | ||
"username": "u83188312", | ||
"password": "zhx571", | ||
"type": "Pay by bank" | ||
}, | ||
{ | ||
"username": "u92721594", | ||
"password": "nbs589", | ||
"type": "Pay by bank" | ||
}, | ||
{ | ||
"username": "u91902655", | ||
"password": "jtx720", | ||
"type": "Pay by bank" | ||
} | ||
] |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.adyen.testcards | ||
|
||
import android.app.Application | ||
import dagger.hilt.android.HiltAndroidApp | ||
|
||
@HiltAndroidApp | ||
class App : Application() |
75 changes: 75 additions & 0 deletions
75
app/src/main/java/com/adyen/testcards/autofill/AdyenTestCardsAutofillService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package com.adyen.testcards.autofill | ||
|
||
import android.app.PendingIntent | ||
import android.os.Build | ||
import android.os.CancellationSignal | ||
import android.service.autofill.AutofillService | ||
import android.service.autofill.Dataset | ||
import android.service.autofill.Field | ||
import android.service.autofill.FillCallback | ||
import android.service.autofill.FillRequest | ||
import android.service.autofill.FillResponse | ||
import android.service.autofill.Presentations | ||
import android.service.autofill.SaveCallback | ||
import android.service.autofill.SaveRequest | ||
import android.util.Log | ||
import android.widget.RemoteViews | ||
import com.adyen.testcards.R | ||
import java.util.concurrent.atomic.AtomicInteger | ||
|
||
class AdyenTestCardsAutofillService : AutofillService() { | ||
|
||
private val requestCode = AtomicInteger() | ||
|
||
override fun onFillRequest(request: FillRequest, cancellationSignal: CancellationSignal, callback: FillCallback) { | ||
Log.d(TAG, "onFillRequest") | ||
var pendingIntent: PendingIntent? = null | ||
|
||
cancellationSignal.setOnCancelListener { | ||
try { | ||
pendingIntent?.cancel() | ||
} catch (e: Exception) { | ||
Log.e(TAG, "Error while cancelling pending intent", e) | ||
} | ||
} | ||
|
||
val structure = request.fillContexts.last().structure | ||
val parsedStructure = StructureParser().parse(structure) ?: return | ||
|
||
val responseBuilder = FillResponse.Builder() | ||
|
||
pendingIntent = AutofillActivity.createPendingIntent(this, parsedStructure, requestCode.getAndIncrement()) | ||
val remoteViews = RemoteViews(packageName, R.layout.item_autofill_entry) | ||
|
||
val datasetBuilder = Dataset.Builder() | ||
parsedStructure.allIds().forEach { | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { | ||
val presentations = Presentations.Builder() | ||
.setMenuPresentation(remoteViews) | ||
.setDialogPresentation(remoteViews) | ||
.build() | ||
datasetBuilder.setField( | ||
it, | ||
Field.Builder().setPresentations(presentations).build(), | ||
) | ||
} else { | ||
@Suppress("DEPRECATION") | ||
datasetBuilder.setValue(it, null, remoteViews) | ||
} | ||
} | ||
|
||
datasetBuilder.setAuthentication(pendingIntent.intentSender) | ||
|
||
responseBuilder.addDataset(datasetBuilder.build()) | ||
|
||
callback.onSuccess(responseBuilder.build()) | ||
} | ||
|
||
override fun onSaveRequest(request: SaveRequest, callback: SaveCallback) { | ||
callback.onSuccess() | ||
} | ||
|
||
companion object { | ||
private const val TAG = "TestCardAutofillService" | ||
} | ||
} |
Oops, something went wrong.