├── .idea
├── .name
├── .gitignore
├── compiler.xml
├── kotlinc.xml
├── migrations.xml
├── deploymentTargetSelector.xml
├── misc.xml
├── gradle.xml
└── other.xml
├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── assets
│ │ │ └── teste.jpg
│ │ ├── res
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ └── ic_launcher_round.webp
│ │ │ ├── anim
│ │ │ │ └── shake.xml
│ │ │ ├── drawable
│ │ │ │ ├── baseline_other_32.xml
│ │ │ │ ├── baseline_payment_32.xml
│ │ │ │ ├── ic_arrow_right.xml
│ │ │ │ ├── baseline_print_32.xml
│ │ │ │ ├── baseline_nfc_32.xml
│ │ │ │ ├── btn_rounded_footer.xml
│ │ │ │ ├── btn_rounded.xml
│ │ │ │ └── ic_launcher_background.xml
│ │ │ ├── mipmap-anydpi-v26
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.xml
│ │ │ ├── xml
│ │ │ │ ├── backup_rules.xml
│ │ │ │ └── data_extraction_rules.xml
│ │ │ ├── values
│ │ │ │ ├── colors.xml
│ │ │ │ ├── themes.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ └── strings.xml
│ │ │ ├── menu
│ │ │ │ └── bottom_nav_menu.xml
│ │ │ ├── values-night
│ │ │ │ └── themes.xml
│ │ │ ├── navigation
│ │ │ │ └── mobile_navigation.xml
│ │ │ ├── layout
│ │ │ │ ├── activity_main.xml
│ │ │ │ ├── fragment_print.xml
│ │ │ │ ├── fragment_payment_installment.xml
│ │ │ │ ├── fragment_payment_type_item.xml
│ │ │ │ ├── fragment_nfc.xml
│ │ │ │ └── fragment_other.xml
│ │ │ └── drawable-v24
│ │ │ │ └── ic_launcher_foreground.xml
│ │ ├── java
│ │ │ └── br
│ │ │ │ └── com
│ │ │ │ └── uol
│ │ │ │ └── pagbank
│ │ │ │ └── plugpagservice
│ │ │ │ └── demo
│ │ │ │ ├── di
│ │ │ │ ├── AssetModule.kt
│ │ │ │ ├── PlugPagModule.kt
│ │ │ │ └── PackageManagerModule.kt
│ │ │ │ ├── model
│ │ │ │ ├── State.kt
│ │ │ │ ├── PaymentError.kt
│ │ │ │ ├── PaymentType.kt
│ │ │ │ └── InstallmentType.kt
│ │ │ │ ├── PayApplication.kt
│ │ │ │ ├── MainActivity.kt
│ │ │ │ ├── ui
│ │ │ │ ├── other
│ │ │ │ │ ├── OtherFragment.kt
│ │ │ │ │ └── OtherViewModel.kt
│ │ │ │ ├── payment
│ │ │ │ │ ├── PaymentTypeAdapter.kt
│ │ │ │ │ ├── PaymentInstallmentAdapter.kt
│ │ │ │ │ ├── PaymentViewModel.kt
│ │ │ │ │ └── PaymentFragment.kt
│ │ │ │ ├── print
│ │ │ │ │ ├── PrintFragment.kt
│ │ │ │ │ └── PrintViewModel.kt
│ │ │ │ └── nfc
│ │ │ │ │ ├── NFCFragment.kt
│ │ │ │ │ └── NFCViewModel.kt
│ │ │ │ └── extensions
│ │ │ │ └── View.kt
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── br
│ │ │ └── com
│ │ │ └── uol
│ │ │ └── pagbank
│ │ │ └── apppay
│ │ │ └── ExampleUnitTest.kt
│ └── androidTest
│ │ └── java
│ │ └── br
│ │ └── com
│ │ └── uol
│ │ └── pagbank
│ │ └── apppay
│ │ └── ExampleInstrumentedTest.kt
├── proguard-rules.pro
└── build.gradle.kts
├── gradle
├── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
└── libs.versions.toml
├── .gitignore
├── README.md
├── settings.gradle.kts
├── gradle.properties
├── gradlew.bat
└── gradlew
/.idea/.name:
--------------------------------------------------------------------------------
1 | DemoPPS
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 |
--------------------------------------------------------------------------------
/app/src/main/assets/teste.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pagseguro/pagseguro-plugpagservicewrapper-smartcoffeedemo/HEAD/app/src/main/assets/teste.jpg
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pagseguro/pagseguro-plugpagservicewrapper-smartcoffeedemo/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pagseguro/pagseguro-plugpagservicewrapper-smartcoffeedemo/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pagseguro/pagseguro-plugpagservicewrapper-smartcoffeedemo/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pagseguro/pagseguro-plugpagservicewrapper-smartcoffeedemo/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pagseguro/pagseguro-plugpagservicewrapper-smartcoffeedemo/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pagseguro/pagseguro-plugpagservicewrapper-smartcoffeedemo/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pagseguro/pagseguro-plugpagservicewrapper-smartcoffeedemo/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pagseguro/pagseguro-plugpagservicewrapper-smartcoffeedemo/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pagseguro/pagseguro-plugpagservicewrapper-smartcoffeedemo/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pagseguro/pagseguro-plugpagservicewrapper-smartcoffeedemo/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pagseguro/pagseguro-plugpagservicewrapper-smartcoffeedemo/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/kotlinc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Jun 21 13:37:41 BRT 2024
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
5 | zipStoreBase=GRADLE_USER_HOME
6 | zipStorePath=wrapper/dists
7 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 | .cxx
15 | local.properties
16 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/uol/pagbank/plugpagservice/demo/di/AssetModule.kt:
--------------------------------------------------------------------------------
1 | package br.com.uol.pagbank.plugpagservice.demo.di
2 |
3 | import android.content.Context
4 | import org.koin.dsl.module
5 |
6 | val assetModule = module {
7 | single(createdAtStart = true) { (get() as Context).assets }
8 | }
9 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/uol/pagbank/plugpagservice/demo/model/State.kt:
--------------------------------------------------------------------------------
1 | package br.com.uol.pagbank.plugpagservice.demo.model
2 |
3 | enum class State {
4 | GETTING_AMOUNT,
5 | GETTING_TYPE,
6 | GETTING_INSTALLMENT_TYPE,
7 | GETTING_INSTALLMENTS,
8 | PAYING,
9 | RESULT,
10 | }
11 |
--------------------------------------------------------------------------------
/.idea/migrations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/uol/pagbank/plugpagservice/demo/di/PlugPagModule.kt:
--------------------------------------------------------------------------------
1 | package br.com.uol.pagbank.plugpagservice.demo.di
2 |
3 | import br.com.uol.pagseguro.plugpagservice.wrapper.PlugPag
4 | import org.koin.dsl.module
5 |
6 | val plugpagModule = module {
7 | single(createdAtStart = true) { PlugPag(get()) }
8 | }
9 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/uol/pagbank/plugpagservice/demo/di/PackageManagerModule.kt:
--------------------------------------------------------------------------------
1 | package br.com.uol.pagbank.plugpagservice.demo.di
2 |
3 | import android.content.Context
4 | import org.koin.dsl.module
5 |
6 | val packageManagerModule = module {
7 | single(createdAtStart = true) { (get() as Context).packageManager }
8 | }
9 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/uol/pagbank/plugpagservice/demo/model/PaymentError.kt:
--------------------------------------------------------------------------------
1 | package br.com.uol.pagbank.plugpagservice.demo.model
2 |
3 | enum class PaymentError {
4 | INVALID_AMOUNT,
5 | INVALID_TYPE,
6 | INVALID_INSTALLMENT_TYPE,
7 | INVALID_INSTALLMENTS,
8 | INVALID_STATE,
9 | INVALID_SETUP,
10 | }
11 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # SmartCoffee (Demo PPS)
2 |
3 | Demonstração de como implementar o PlugPagServiceWrapper em uma aplicação Android na Moderninha Smart.
4 |
5 |
6 | ## PlugPagServiceWrapper
7 |
8 | Instruções de como adicionar o PlugPagServiceWrapper na sua aplicação podem ser encontradas [aqui](https://github.com/pagseguro/PlugPagServiceWrapper).
9 |
--------------------------------------------------------------------------------
/.idea/deploymentTargetSelector.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/shake.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/baseline_other_32.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/uol/pagbank/plugpagservice/demo/model/PaymentType.kt:
--------------------------------------------------------------------------------
1 | package br.com.uol.pagbank.plugpagservice.demo.model
2 |
3 | import br.com.uol.pagseguro.plugpagservice.wrapper.PlugPag
4 |
5 | enum class PaymentType(
6 | val value: Int
7 | ) {
8 | DEBIT(PlugPag.TYPE_DEBITO),
9 | CREDIT(PlugPag.TYPE_CREDITO),
10 | VOUCHER(PlugPag.TYPE_VOUCHER),
11 | PIX(PlugPag.TYPE_PIX),
12 | }
13 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/uol/pagbank/plugpagservice/demo/model/InstallmentType.kt:
--------------------------------------------------------------------------------
1 | package br.com.uol.pagbank.plugpagservice.demo.model
2 |
3 | import br.com.uol.pagseguro.plugpagservice.wrapper.PlugPag
4 |
5 | enum class InstallmentType(
6 | val value: Int
7 | ) {
8 | A_VISTA(PlugPag.INSTALLMENT_TYPE_A_VISTA),
9 | PARC_VENDEDOR(PlugPag.INSTALLMENT_TYPE_PARC_VENDEDOR),
10 | PARC_COMPRADOR(PlugPag.INSTALLMENT_TYPE_PARC_COMPRADOR),
11 | }
12 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/baseline_payment_32.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/test/java/br/com/uol/pagbank/apppay/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package br.com.uol.pagbank.plugpagservice.demo
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_arrow_right.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
11 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/baseline_print_32.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/backup_rules.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/baseline_nfc_32.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/data_extraction_rules.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
12 |
13 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/btn_rounded_footer.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 | -
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/btn_rounded.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 |
10 | -
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | pluginManagement {
2 | repositories {
3 | google {
4 | content {
5 | includeGroupByRegex("com\\.android.*")
6 | includeGroupByRegex("com\\.google.*")
7 | includeGroupByRegex("androidx.*")
8 | }
9 | }
10 | mavenCentral()
11 | gradlePluginPortal()
12 | }
13 | }
14 | dependencyResolutionManagement {
15 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
16 | repositories {
17 | google()
18 | mavenCentral()
19 | maven { setUrl("https://github.com/pagseguro/PlugPagServiceWrapper/raw/master") }
20 | }
21 | }
22 |
23 | rootProject.name = "DemoPPS"
24 | include(":app")
25 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFBB86FC
4 | #FF6200EE
5 | #FF3700B3
6 | #FF03DAC5
7 | #FF018786
8 | #FF000000
9 | #FFFFFFFF
10 | #FFD9D9D9
11 | #FFE0E255
12 | #FF08CE3F
13 | #FDFFFFFF
14 | #60000000
15 | #40000000
16 | #B0B0B0
17 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/uol/pagbank/plugpagservice/demo/PayApplication.kt:
--------------------------------------------------------------------------------
1 | package br.com.uol.pagbank.plugpagservice.demo
2 |
3 | import android.app.Application
4 | import br.com.uol.pagbank.plugpagservice.demo.di.assetModule
5 | import br.com.uol.pagbank.plugpagservice.demo.di.packageManagerModule
6 | import br.com.uol.pagbank.plugpagservice.demo.di.plugpagModule
7 | import org.koin.android.ext.koin.androidContext
8 | import org.koin.core.context.startKoin
9 |
10 | class PayApplication : Application() {
11 | override fun onCreate() {
12 | super.onCreate()
13 |
14 | startKoin {
15 | androidContext(this@PayApplication)
16 | modules(plugpagModule)
17 | modules(packageManagerModule)
18 | modules(assetModule)
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/app/src/main/res/menu/bottom_nav_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
26 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/br/com/uol/pagbank/apppay/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package br.com.uol.pagbank.plugpagservice.demo
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("br.com.uol.pagbank.plugpagservice.demo", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/app/src/main/res/values-night/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 | 300dp
6 | 200dp
7 | 100dp
8 | 50dp
9 | 80dp
10 | 60dp
11 | 10dp
12 | 30sp
13 | 24sp
14 | 5dp
15 | 10dp
16 | 18sp
17 | 14sp
18 | 18sp
19 | 25sp
20 | 30sp
21 | 5dp
22 | 5dp
23 | 5dp
24 | 30dp
25 |
--------------------------------------------------------------------------------
/app/src/main/res/navigation/mobile_navigation.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
19 |
20 |
25 |
26 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. For more details, visit
12 | # https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app's APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Kotlin code style for this project: "official" or "obsolete":
19 | kotlin.code.style=official
20 | # Enables namespacing of each library's R class so that its R class includes only the
21 | # resources declared in the library itself and none from the library's dependencies,
22 | # thereby reducing the size of the R class for that library
23 | android.nonTransitiveRClass=true
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
8 |
10 |
11 |
12 |
23 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
21 |
22 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/uol/pagbank/plugpagservice/demo/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package br.com.uol.pagbank.plugpagservice.demo
2 |
3 | import android.os.Bundle
4 | import android.view.KeyEvent
5 | import com.google.android.material.bottomnavigation.BottomNavigationView
6 | import androidx.appcompat.app.AppCompatActivity
7 | import androidx.navigation.findNavController
8 | import androidx.navigation.fragment.NavHostFragment
9 | import androidx.navigation.ui.AppBarConfiguration
10 | import androidx.navigation.ui.setupActionBarWithNavController
11 | import androidx.navigation.ui.setupWithNavController
12 | import br.com.uol.pagbank.plugpagservice.demo.databinding.ActivityMainBinding
13 | import br.com.uol.pagbank.plugpagservice.demo.ui.payment.PaymentFragment
14 |
15 | class MainActivity : AppCompatActivity() {
16 | private lateinit var binding: ActivityMainBinding
17 | private lateinit var navHostFragment: NavHostFragment
18 |
19 | override fun onCreate(savedInstanceState: Bundle?) {
20 | super.onCreate(savedInstanceState)
21 |
22 | binding = ActivityMainBinding.inflate(layoutInflater)
23 | setContentView(binding.root)
24 |
25 | val navView: BottomNavigationView = binding.navView
26 |
27 | val navController = findNavController(R.id.nav_host_fragment_activity_main)
28 | val appBarConfiguration = AppBarConfiguration(
29 | setOf(
30 | R.id.navigation_payment,
31 | R.id.navigation_nfc,
32 | R.id.navigation_print,
33 | R.id.navigation_other,
34 | )
35 | )
36 | setupActionBarWithNavController(navController, appBarConfiguration)
37 | navView.setupWithNavController(navController)
38 |
39 | navHostFragment = supportFragmentManager
40 | .findFragmentById(R.id.nav_host_fragment_activity_main) as NavHostFragment
41 | }
42 |
43 | override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
44 | val currentFragment = navHostFragment.childFragmentManager.fragments[0]
45 | if (currentFragment is PaymentFragment) {
46 | if (currentFragment.onKeyPressed(keyCode)) {
47 | return true
48 | }
49 | }
50 |
51 | return super.onKeyDown(keyCode, event)
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_print.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
24 |
25 |
35 |
36 |
37 |
38 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_payment_installment.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
22 |
23 |
31 |
32 |
42 |
43 |
54 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_payment_type_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
25 |
26 |
35 |
36 |
47 |
48 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/app/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | alias(libs.plugins.android.application)
3 | alias(libs.plugins.jetbrains.kotlin.android)
4 | }
5 |
6 | android {
7 | namespace = "br.com.uol.pagbank.plugpagservice.demo"
8 | compileSdk = 34
9 |
10 | defaultConfig {
11 | applicationId = "br.com.uol.pagbank.plugpagservice.demo"
12 | minSdk = 23
13 | targetSdk = 34
14 | versionCode = 1
15 | versionName = "1.29.0"
16 |
17 | testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
18 | }
19 |
20 | buildTypes {
21 | release {
22 | isMinifyEnabled = false
23 | proguardFiles(
24 | getDefaultProguardFile("proguard-android-optimize.txt"),
25 | "proguard-rules.pro"
26 | )
27 | }
28 | }
29 | compileOptions {
30 | sourceCompatibility = JavaVersion.VERSION_17
31 | targetCompatibility = JavaVersion.VERSION_17
32 | }
33 | kotlinOptions {
34 | jvmTarget = JavaVersion.VERSION_17.toString()
35 | }
36 | buildFeatures {
37 | viewBinding = true
38 | compose = true
39 | }
40 | composeOptions {
41 | kotlinCompilerExtensionVersion = "1.5.2"
42 | }
43 | packaging {
44 | resources {
45 | excludes += "/META-INF/{AL2.0,LGPL2.1}"
46 | }
47 | }
48 | }
49 |
50 | dependencies {
51 | implementation(libs.plugpagwrapper)
52 |
53 | implementation(libs.androidx.core.ktx)
54 | implementation(libs.androidx.appcompat)
55 | implementation(libs.material)
56 | implementation(libs.androidx.constraintlayout)
57 | implementation(libs.androidx.lifecycle.livedata.ktx)
58 | implementation(libs.androidx.lifecycle.viewmodel.ktx)
59 | implementation(libs.androidx.navigation.fragment.ktx)
60 | implementation(libs.androidx.navigation.ui.ktx)
61 | implementation(libs.androidx.activity.compose)
62 | implementation(platform(libs.androidx.compose))
63 | implementation(libs.androidx.compose.ui)
64 | implementation(libs.androidx.compose.ui.graphics)
65 | implementation(libs.androidx.compose.ui.tooling.preview)
66 | implementation(libs.androidx.compose.material3)
67 |
68 | implementation(libs.koin.core)
69 | implementation(libs.koin.android)
70 | // implementation(libs.koin.androidx.viewmodel)
71 |
72 | testImplementation(libs.junit)
73 |
74 | androidTestImplementation(libs.androidx.junit)
75 | androidTestImplementation(libs.androidx.espresso.core)
76 | }
77 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/uol/pagbank/plugpagservice/demo/ui/other/OtherFragment.kt:
--------------------------------------------------------------------------------
1 | package br.com.uol.pagbank.plugpagservice.demo.ui.other
2 |
3 | import android.os.Bundle
4 | import android.view.LayoutInflater
5 | import android.view.View
6 | import android.view.ViewGroup
7 | import android.widget.TextView
8 | import androidx.fragment.app.Fragment
9 | import androidx.lifecycle.ViewModelProvider
10 | import br.com.uol.pagbank.plugpagservice.demo.databinding.FragmentOtherBinding
11 |
12 | class OtherFragment : Fragment() {
13 | private var _binding: FragmentOtherBinding? = null
14 | private val binding get() = _binding!!
15 |
16 | private lateinit var otherViewModel: OtherViewModel
17 |
18 | override fun onCreateView(
19 | inflater: LayoutInflater,
20 | container: ViewGroup?,
21 | savedInstanceState: Bundle?
22 | ): View {
23 | otherViewModel = ViewModelProvider(this).get(OtherViewModel::class.java)
24 | _binding = FragmentOtherBinding.inflate(inflater, container, false)
25 | val root: View = binding.root
26 |
27 | configViews()
28 |
29 | return root
30 | }
31 |
32 | private fun configViews() {
33 | val textView: TextView = binding.tvOther
34 | otherViewModel.eventText.observe(viewLifecycleOwner) {
35 | textView.text = it
36 | }
37 | otherViewModel.eventTextResource.observe(viewLifecycleOwner) {
38 | textView.text = requireContext().getText(it)
39 | }
40 | otherViewModel.eventModelText.observe(viewLifecycleOwner) {
41 | binding.tvModel.text = it
42 | }
43 | otherViewModel.eventSerialNumber.observe(viewLifecycleOwner) {
44 | binding.tvSerialNumber.text = it
45 | }
46 | binding.btnOtherReboot.setOnClickListener { otherViewModel.reboot() }
47 | binding.btnOtherBeep.setOnClickListener { otherViewModel.beep() }
48 | binding.btnOtherLed.setOnClickListener { otherViewModel.led() }
49 | binding.btnOtherLastTransaction.setOnClickListener { otherViewModel.lastTransaction() }
50 | binding.btnOtherReprintEstablishmentReceipt.setOnClickListener { otherViewModel.reprintEstablishmentReceipt() }
51 | binding.btnOtherReprintCustomerReceipt.setOnClickListener { otherViewModel.reprintCustomerReceipt() }
52 | binding.btnOtherUndoLastTransaction.setOnClickListener { otherViewModel.undoLastTransaction() }
53 | }
54 |
55 | override fun onDestroyView() {
56 | super.onDestroyView()
57 | _binding = null
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/gradle/libs.versions.toml:
--------------------------------------------------------------------------------
1 | [versions]
2 | agp = "8.4.0"
3 | kotlin = "1.9.0"
4 | coreKtx = "1.13.1"
5 | plugpagwrapper = "1.30.52"
6 | junit = "4.13.2"
7 | junitVersion = "1.1.5"
8 | espressoCore = "3.5.1"
9 | appcompat = "1.7.0"
10 | material = "1.12.0"
11 | constraintlayout = "2.1.4"
12 | lifecycleLivedataKtx = "2.8.2"
13 | lifecycleViewmodelKtx = "2.8.2"
14 | navigationFragmentKtx = "2.7.7"
15 | navigationUiKtx = "2.7.7"
16 | activityCompose = "1.7.2"
17 | composeBom = "2023.03.00"
18 | koin = "3.1.0"
19 |
20 | [libraries]
21 | androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
22 | plugpagwrapper = { group = "br.com.uol.pagseguro.plugpagservice.wrapper", name = "wrapper", version.ref = "plugpagwrapper" }
23 | junit = { group = "junit", name = "junit", version.ref = "junit" }
24 | androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
25 | androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
26 | androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
27 | material = { group = "com.google.android.material", name = "material", version.ref = "material" }
28 | androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" }
29 | androidx-lifecycle-livedata-ktx = { group = "androidx.lifecycle", name = "lifecycle-livedata-ktx", version.ref = "lifecycleLivedataKtx" }
30 | androidx-lifecycle-viewmodel-ktx = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-ktx", version.ref = "lifecycleViewmodelKtx" }
31 | androidx-navigation-fragment-ktx = { group = "androidx.navigation", name = "navigation-fragment-ktx", version.ref = "navigationFragmentKtx" }
32 | androidx-navigation-ui-ktx = { group = "androidx.navigation", name = "navigation-ui-ktx", version.ref = "navigationUiKtx" }
33 | androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activityCompose" }
34 | androidx-compose = { group = "androidx.compose", name = "compose-bom", version.ref = "composeBom" }
35 | androidx-compose-ui = { group = "androidx.compose.ui", name = "ui" }
36 | androidx-compose-ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" }
37 | androidx-compose-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" }
38 | androidx-compose-material3 = { group = "androidx.compose.material3", name = "material3" }
39 | koin-core = { group = "io.insert-koin", name = "koin-core", version.ref = "koin" }
40 | koin-android = { group = "io.insert-koin", name = "koin-android", version.ref = "koin" }
41 | koin-androidx-viewmodel = { group = "io.insert-koin", name = "koin-androidx-viewmodel", version.ref = "koin" }
42 |
43 | [plugins]
44 | android-application = { id = "com.android.application", version.ref = "agp" }
45 | jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
46 |
47 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/uol/pagbank/plugpagservice/demo/ui/payment/PaymentTypeAdapter.kt:
--------------------------------------------------------------------------------
1 | package br.com.uol.pagbank.plugpagservice.demo.ui.payment
2 |
3 | import android.content.Context
4 | import android.view.LayoutInflater
5 | import android.view.View
6 | import android.view.ViewGroup
7 | import android.widget.TextView
8 | import androidx.recyclerview.widget.RecyclerView
9 | import br.com.uol.pagbank.plugpagservice.demo.R
10 | import java.io.Serializable
11 |
12 | class PaymentTypeAdapter(
13 | context: Context
14 | ) : RecyclerView.Adapter() {
15 | private var inflater: LayoutInflater = LayoutInflater.from(context)
16 |
17 | private var data: List = listOf()
18 | private var clickListener: ItemClickListener? = null
19 |
20 | fun setData(newData: List?) {
21 | this.data = newData ?: listOf()
22 | this.notifyDataSetChanged()
23 | }
24 |
25 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
26 | val view: View = inflater.inflate(
27 | R.layout.fragment_payment_type_item,
28 | parent,
29 | false
30 | )
31 | return ViewHolder(view)
32 | }
33 |
34 | override fun onBindViewHolder(holder: ViewHolder, position: Int) {
35 | holder.setData(
36 | data[position],
37 | clickListener
38 | )
39 | }
40 |
41 | override fun getItemCount() = data.size
42 |
43 | fun getItem(id: Int) = data[id]
44 |
45 | fun setClickListener(itemClickListener: ItemClickListener?) {
46 | this.clickListener = itemClickListener
47 | }
48 |
49 | interface ItemClickListener {
50 | fun onItemClick(view: View?, paymentType: PlugPagType?)
51 | }
52 |
53 | class ViewHolder internal constructor(
54 | itemView: View
55 | ) : RecyclerView.ViewHolder(itemView), View.OnClickListener {
56 | private var plugPagType: PlugPagType? = null
57 | private var clickListener: ItemClickListener? = null
58 |
59 | private var tvTypeNumber: TextView =
60 | itemView.findViewById(R.id.tvTypeNumber)
61 | private var tvTypeDescription: TextView =
62 | itemView.findViewById(R.id.tvTypeDescription)
63 |
64 | init {
65 | itemView.setOnClickListener(this)
66 | }
67 |
68 | fun setData(plugPagType: PlugPagType, clickListener: ItemClickListener?) {
69 | this.plugPagType = plugPagType
70 | this.clickListener = clickListener
71 |
72 | this.tvTypeNumber.text = plugPagType.index.toString()
73 | this.tvTypeDescription.text = plugPagType.description
74 | }
75 |
76 | override fun onClick(view: View) {
77 | clickListener?.onItemClick(view, plugPagType)
78 | }
79 | }
80 |
81 | data class PlugPagType(val index: Int, val description: String, val type: Any) :
82 | Serializable {
83 | override fun toString() = "\"${index}, $description, ${type}\""
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/uol/pagbank/plugpagservice/demo/extensions/View.kt:
--------------------------------------------------------------------------------
1 | package br.com.uol.pagbank.plugpagservice.demo.extensions
2 |
3 | import android.view.View
4 | import android.view.animation.AccelerateInterpolator
5 | import android.view.animation.AlphaAnimation
6 | import android.view.animation.Animation
7 | import android.view.animation.AnimationSet
8 | import android.view.animation.DecelerateInterpolator
9 |
10 | private const val ANIMATION_DURATION = 250L
11 |
12 | private fun loadAnimationFadeIn(): Animation {
13 | return AlphaAnimation(0f, 1f).apply {
14 | interpolator = AccelerateInterpolator()
15 | setDuration(ANIMATION_DURATION)
16 | }
17 | }
18 |
19 | private fun loadAnimationGetIn(): Animation {
20 | val fadeIn = loadAnimationFadeIn()
21 | val moveIn = android.view.animation.TranslateAnimation(0f, 0f, +100f, 0f).apply {
22 | interpolator = DecelerateInterpolator()
23 | setDuration(ANIMATION_DURATION)
24 | }
25 |
26 | return AnimationSet(false).apply {
27 | addAnimation(fadeIn)
28 | addAnimation(moveIn)
29 | }
30 | }
31 |
32 | private fun loadAnimationFadeOut(): Animation {
33 | return AlphaAnimation(1f, 0f).apply {
34 | interpolator = AccelerateInterpolator()
35 | setDuration(ANIMATION_DURATION)
36 | }
37 | }
38 |
39 | private fun loadAnimationGetOut(): Animation {
40 | val fadeOut = loadAnimationFadeOut()
41 | val moveOut = android.view.animation.TranslateAnimation(0f, 0f, 0f, +100f).apply {
42 | interpolator = DecelerateInterpolator()
43 | setDuration(ANIMATION_DURATION)
44 | }
45 |
46 | return AnimationSet(false).apply {
47 | addAnimation(fadeOut)
48 | addAnimation(moveOut)
49 | }
50 | }
51 |
52 | fun View.fadeIn() {
53 | if (visibility == View.VISIBLE) return
54 |
55 | visibility = View.VISIBLE
56 | startAnimation(loadAnimationFadeIn())
57 | }
58 |
59 | fun View.getIn() {
60 | if (visibility == View.VISIBLE) return
61 |
62 | visibility = View.VISIBLE
63 | startAnimation(loadAnimationGetIn())
64 | }
65 |
66 | fun View.fadeOut() {
67 | if (visibility == View.GONE) return
68 |
69 | val fadeOut = loadAnimationFadeOut()
70 | fadeOut.setAnimationListener(object : Animation.AnimationListener {
71 | override fun onAnimationStart(animation: Animation?) {}
72 | override fun onAnimationRepeat(animation: Animation?) {}
73 |
74 | override fun onAnimationEnd(animation: Animation?) {
75 | visibility = View.GONE
76 | }
77 | })
78 |
79 | startAnimation(fadeOut)
80 | }
81 |
82 | fun View.getOut() {
83 | if (visibility == View.GONE) return
84 |
85 | val getOut = loadAnimationGetOut()
86 | getOut.setAnimationListener(object : Animation.AnimationListener {
87 | override fun onAnimationStart(animation: Animation?) {}
88 | override fun onAnimationRepeat(animation: Animation?) {}
89 |
90 | override fun onAnimationEnd(animation: Animation?) {
91 | visibility = View.GONE
92 | }
93 | })
94 |
95 | startAnimation(getOut)
96 | }
97 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/uol/pagbank/plugpagservice/demo/ui/payment/PaymentInstallmentAdapter.kt:
--------------------------------------------------------------------------------
1 | package br.com.uol.pagbank.plugpagservice.demo.ui.payment
2 |
3 | import android.content.Context
4 | import android.view.LayoutInflater
5 | import android.view.View
6 | import android.view.ViewGroup
7 | import android.widget.TextView
8 | import androidx.recyclerview.widget.RecyclerView
9 | import br.com.uol.pagbank.plugpagservice.demo.R
10 | import br.com.uol.pagseguro.plugpagservice.wrapper.PlugPagInstallment
11 |
12 | class PaymentInstallmentAdapter(
13 | context: Context
14 | ): RecyclerView.Adapter() {
15 | private var inflater: LayoutInflater = LayoutInflater.from(context)
16 |
17 | private var data: List = listOf()
18 | private var clickListener: ItemClickListener? = null
19 |
20 | fun setData(newData: List?) {
21 | this.data = newData ?: listOf()
22 | this.notifyDataSetChanged()
23 | }
24 |
25 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
26 | val view: View = inflater.inflate(
27 | R.layout.fragment_payment_installment,
28 | parent,
29 | false
30 | )
31 | return ViewHolder(view)
32 | }
33 |
34 | override fun onBindViewHolder(holder: ViewHolder, position: Int) {
35 | holder.setData(
36 | data[position],
37 | clickListener
38 | )
39 | }
40 |
41 | override fun getItemCount() = data.size
42 |
43 | fun getItem(id: Int) = data[id]
44 |
45 | fun setClickListener(itemClickListener: ItemClickListener?) {
46 | this.clickListener = itemClickListener
47 | }
48 |
49 | interface ItemClickListener {
50 | fun onItemClick(view: View?, ppInstallment: PlugPagInstallment?, position: Int)
51 | }
52 |
53 | class ViewHolder internal constructor(
54 | itemView: View
55 | ): RecyclerView.ViewHolder(itemView), View.OnClickListener {
56 | private var plugPagInstallment: PlugPagInstallment? = null
57 | private var clickListener: ItemClickListener? = null
58 |
59 | private var tvInstallmentAmount: TextView = itemView.findViewById(R.id.tvInstallmentAmount)
60 | private var tvInstallmentValue: TextView = itemView.findViewById(R.id.tvInstallmentValue)
61 | private var tvInstallmentTotalValue: TextView = itemView.findViewById(R.id.tvInstallmentTotalValue)
62 |
63 | init {
64 | itemView.setOnClickListener(this)
65 | }
66 |
67 | fun setData(plugPagInstallment: PlugPagInstallment, clickListener: ItemClickListener?) {
68 | this.plugPagInstallment = plugPagInstallment
69 | this.clickListener = clickListener
70 |
71 | this.tvInstallmentAmount.text = "${plugPagInstallment.quantity} x"
72 | this.tvInstallmentValue.text = "%.2f".format(plugPagInstallment.amount / 100f)
73 | this.tvInstallmentTotalValue.text = "= %.2f".format(plugPagInstallment.total / 100f)
74 | }
75 |
76 | override fun onClick(view: View) {
77 | clickListener?.onItemClick(view, plugPagInstallment, adapterPosition)
78 | }
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/uol/pagbank/plugpagservice/demo/ui/print/PrintFragment.kt:
--------------------------------------------------------------------------------
1 | package br.com.uol.pagbank.plugpagservice.demo.ui.print
2 |
3 | import android.Manifest
4 | import android.content.pm.PackageManager
5 | import android.os.Build
6 | import android.os.Bundle
7 | import android.os.Environment
8 | import android.view.LayoutInflater
9 | import android.view.View
10 | import android.view.ViewGroup
11 | import android.widget.TextView
12 | import androidx.activity.result.contract.ActivityResultContracts
13 | import androidx.core.content.ContextCompat
14 | import androidx.fragment.app.Fragment
15 | import androidx.lifecycle.ViewModelProvider
16 | import br.com.uol.pagbank.plugpagservice.demo.databinding.FragmentPrintBinding
17 |
18 | class PrintFragment : Fragment() {
19 | private var _binding: FragmentPrintBinding? = null
20 | private val binding get() = _binding!!
21 |
22 | private lateinit var printViewModel: PrintViewModel
23 |
24 | private val neededPermissionsList = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
25 | listOf(
26 | "android.permission.READ_MEDIA_IMAGES",
27 | )
28 | } else {
29 | listOf(
30 | Manifest.permission.READ_EXTERNAL_STORAGE,
31 | Manifest.permission.WRITE_EXTERNAL_STORAGE,
32 | )
33 | }
34 |
35 | private val permissionLauncher = registerForActivityResult(
36 | ActivityResultContracts.RequestMultiplePermissions()
37 | ) {
38 | printViewModel.hasNeedWritePermission(neededPermissions().isNotEmpty())
39 | }
40 |
41 | override fun onCreateView(
42 | inflater: LayoutInflater,
43 | container: ViewGroup?,
44 | savedInstanceState: Bundle?
45 | ): View {
46 | printViewModel = ViewModelProvider(this).get(PrintViewModel::class.java)
47 | _binding = FragmentPrintBinding.inflate(inflater, container, false)
48 | val root: View = binding.root
49 |
50 | configViews()
51 |
52 | return root
53 | }
54 |
55 | private fun configViews() {
56 | val textView: TextView = binding.tvPrint
57 | printViewModel.eventText.observe(viewLifecycleOwner) {
58 | textView.text = it
59 | }
60 | printViewModel.eventTextResource.observe(viewLifecycleOwner) {
61 | textView.text = requireContext().getText(it)
62 | }
63 | printViewModel.hasNeedWritePermission(neededPermissions().isNotEmpty())
64 | printViewModel.needWritePermission.observe(viewLifecycleOwner) { request ->
65 | if (request) requestPermissions()
66 | }
67 |
68 | binding.btnPrintInternal.setOnClickListener {
69 | printViewModel.print(context?.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS)?.absolutePath ?: "")
70 | }
71 | }
72 |
73 | private fun neededPermissions(): List {
74 | return neededPermissionsList.filter {
75 | ContextCompat.checkSelfPermission(
76 | requireContext(), it
77 | ) != PackageManager.PERMISSION_GRANTED
78 | }
79 | }
80 |
81 | private fun requestPermissions() {
82 | neededPermissions().takeIf { it.isNotEmpty() }?.run {
83 | permissionLauncher.launch(neededPermissionsList.toTypedArray())
84 | }
85 | }
86 |
87 | override fun onDestroyView() {
88 | super.onDestroyView()
89 | _binding = null
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Demo PPS
3 |
4 | Aguardando
5 |
6 |
7 | Pagamento
8 |
9 |
10 | AC
11 | 0
12 | 1
13 | 2
14 | 3
15 | 4
16 | 5
17 | 6
18 | 7
19 | 8
20 | 9
21 | Pagar
22 | Tipo de venda:
23 | Tipo de parcelamento:
24 | Quantidade de parcelas:
25 | Débito
26 | Crédito
27 | Voucher
28 | Pix
29 | À vista
30 | Parcelado vendedor
31 | Parcelado comprador
32 | Cancelar
33 | Tentar novamente
34 | Tentar novamente\nComo crédito
35 | Tentar novamente\nComo débito
36 | Tentar novamente\nComo voucher
37 | Voltar
38 | Processando
39 | Sucesso!
40 | Não ativado
41 | Sem serviço de pagamento
42 |
43 |
44 | NFC
45 | Detect
46 | Remove
47 | Read
48 | Read Lot
49 | Read Directly
50 | Write
51 | Write Lot
52 | Write Directly
53 | Auth
54 | Auth Directly
55 |
56 |
57 | Impressão
58 | Imprimir
59 | Verificando existência de arquivo
60 | Apagando arquivo pré-existente
61 | Copiando para diratório compartilhado
62 | Não foi possível criar o arquivo
63 | Imprimindo arquivo
64 |
65 |
66 | Outros
67 | Reiniciar
68 | Reiniciando...
69 | Beep
70 | Beepando na frequência
71 | LED
72 | LED piscando
73 | Ultima transação
74 | Dados
75 | Sem dados de transação
76 | Imprimir via do estabelecimento
77 | Imprimindo via do estabelecimento
78 | Imprimir via do cliente
79 | Imprimindo via do cliente
80 | Estornar
81 | Estornando
82 | Informações do terminal
83 |
84 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/uol/pagbank/plugpagservice/demo/ui/print/PrintViewModel.kt:
--------------------------------------------------------------------------------
1 | package br.com.uol.pagbank.plugpagservice.demo.ui.print
2 |
3 | import android.content.res.AssetManager
4 | import androidx.lifecycle.LiveData
5 | import androidx.lifecycle.MutableLiveData
6 | import androidx.lifecycle.ViewModel
7 | import androidx.lifecycle.viewModelScope
8 | import br.com.uol.pagbank.plugpagservice.demo.R
9 | import br.com.uol.pagseguro.plugpagservice.wrapper.PlugPag
10 | import br.com.uol.pagseguro.plugpagservice.wrapper.PlugPagPrintResult
11 | import br.com.uol.pagseguro.plugpagservice.wrapper.PlugPagPrinterData
12 | import br.com.uol.pagseguro.plugpagservice.wrapper.exception.PlugPagException
13 | import kotlinx.coroutines.Dispatchers
14 | import kotlinx.coroutines.delay
15 | import kotlinx.coroutines.launch
16 | import org.koin.mp.KoinPlatformTools
17 | import java.io.File
18 | import java.io.FileOutputStream
19 | import java.io.InputStream
20 | import java.io.OutputStream
21 |
22 | class PrintViewModel : ViewModel() {
23 | private val plugpag: PlugPag by lazy { KoinPlatformTools.defaultContext().get().get() }
24 | private val assets: AssetManager by lazy { KoinPlatformTools.defaultContext().get().get() }
25 |
26 | companion object {
27 | private const val TWO_SECONDS_DELAY = 2000L
28 | private const val FILE_NAME = "teste.jpg"
29 | }
30 |
31 | // atualiza a mensagem exibida na tela
32 | private val _eventTextResource = MutableLiveData().apply {
33 | value = R.string.waiting
34 | }
35 | val eventTextResource: LiveData = _eventTextResource
36 |
37 | // atualiza a mensagem exibida na tela
38 | private val _eventText = MutableLiveData().apply {
39 | value = ""
40 | }
41 | val eventText: LiveData = _eventText
42 |
43 | // solicita permissões de escrita
44 | private val _needWritePermission = MutableLiveData().apply {
45 | value = false
46 | }
47 | val needWritePermission: LiveData = _needWritePermission
48 |
49 | init {
50 | resetMessage()
51 | }
52 |
53 | private fun resetMessage() {
54 | viewModelScope.launch {
55 | _eventTextResource.value = R.string.waiting
56 | }
57 | }
58 |
59 | private fun setMessage(message: Int) {
60 | viewModelScope.launch {
61 | _eventTextResource.value = message
62 | }
63 | }
64 |
65 | private fun endMessage(message: Int) {
66 | viewModelScope.launch {
67 | _eventTextResource.value = message
68 | delay(TWO_SECONDS_DELAY)
69 | resetMessage()
70 | }
71 | }
72 |
73 | private fun endMessage(message: String) {
74 | viewModelScope.launch {
75 | _eventText.value = message
76 | delay(TWO_SECONDS_DELAY)
77 | resetMessage()
78 | }
79 | }
80 |
81 | private fun endMessage(printResult: PlugPagPrintResult) {
82 | if (printResult.result == PlugPag.RET_OK) {
83 | endMessage(R.string.success)
84 | } else {
85 | endMessage("${printResult.errorCode}\n${printResult.message}")
86 | }
87 | }
88 |
89 | private fun copyFile(inSt: InputStream?, outSt: OutputStream) {
90 | val buffer = ByteArray(1024)
91 | var read: Int? = null
92 | while (inSt?.read(buffer).also { read = it!! } != -1) {
93 | read?.let { outSt.write(buffer, 0, it) }
94 | }
95 | }
96 |
97 | fun hasNeedWritePermission(has: Boolean) {
98 | _needWritePermission.value = !has
99 | }
100 |
101 | fun print(externalDir: String) {
102 | viewModelScope.launch(Dispatchers.IO) {
103 | if (_needWritePermission.value == false) {
104 | viewModelScope.launch {
105 | _needWritePermission.value = true
106 | }
107 | return@launch
108 | }
109 |
110 | setMessage(R.string.print_file_cheking)
111 | val pathExternal = "$externalDir/$FILE_NAME"
112 | val inStInternal = assets.open(FILE_NAME)
113 |
114 | val file = File(pathExternal)
115 | if (file.exists()) {
116 | setMessage(R.string.print_file_deleting)
117 | file.delete()
118 | }
119 |
120 | setMessage(R.string.print_file_copying)
121 | if (file.createNewFile()) {
122 | copyFile(
123 | inStInternal,
124 | FileOutputStream(file)
125 | )
126 | } else {
127 | endMessage(R.string.print_file_cant_create)
128 | return@launch
129 | }
130 |
131 | viewModelScope.launch(Dispatchers.Default) {
132 | setMessage(R.string.print_file_printing)
133 | try {
134 | // executa a impressão do arquivo informado
135 | val result = plugpag.printFromFile(
136 | PlugPagPrinterData(
137 | file.absolutePath,
138 | printerQuality = 4,
139 | steps = 0
140 | )
141 | )
142 |
143 | endMessage(result)
144 | } catch (e: PlugPagException) {
145 | endMessage(e.message ?: "Erro")
146 | }
147 | }
148 | }
149 | }
150 | }
151 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | #
4 | # Copyright 2015 the original author or authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | ##
21 | ## Gradle start up script for UN*X
22 | ##
23 | ##############################################################################
24 |
25 | # Attempt to set APP_HOME
26 | # Resolve links: $0 may be a link
27 | PRG="$0"
28 | # Need this for relative symlinks.
29 | while [ -h "$PRG" ] ; do
30 | ls=`ls -ld "$PRG"`
31 | link=`expr "$ls" : '.*-> \(.*\)$'`
32 | if expr "$link" : '/.*' > /dev/null; then
33 | PRG="$link"
34 | else
35 | PRG=`dirname "$PRG"`"/$link"
36 | fi
37 | done
38 | SAVED="`pwd`"
39 | cd "`dirname \"$PRG\"`/" >/dev/null
40 | APP_HOME="`pwd -P`"
41 | cd "$SAVED" >/dev/null
42 |
43 | APP_NAME="Gradle"
44 | APP_BASE_NAME=`basename "$0"`
45 |
46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
48 |
49 | # Use the maximum available, or set MAX_FD != -1 to use that value.
50 | MAX_FD="maximum"
51 |
52 | warn () {
53 | echo "$*"
54 | }
55 |
56 | die () {
57 | echo
58 | echo "$*"
59 | echo
60 | exit 1
61 | }
62 |
63 | # OS specific support (must be 'true' or 'false').
64 | cygwin=false
65 | msys=false
66 | darwin=false
67 | nonstop=false
68 | case "`uname`" in
69 | CYGWIN* )
70 | cygwin=true
71 | ;;
72 | Darwin* )
73 | darwin=true
74 | ;;
75 | MINGW* )
76 | msys=true
77 | ;;
78 | NONSTOP* )
79 | nonstop=true
80 | ;;
81 | esac
82 |
83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
84 |
85 |
86 | # Determine the Java command to use to start the JVM.
87 | if [ -n "$JAVA_HOME" ] ; then
88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
89 | # IBM's JDK on AIX uses strange locations for the executables
90 | JAVACMD="$JAVA_HOME/jre/sh/java"
91 | else
92 | JAVACMD="$JAVA_HOME/bin/java"
93 | fi
94 | if [ ! -x "$JAVACMD" ] ; then
95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
96 |
97 | Please set the JAVA_HOME variable in your environment to match the
98 | location of your Java installation."
99 | fi
100 | else
101 | JAVACMD="java"
102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
103 |
104 | Please set the JAVA_HOME variable in your environment to match the
105 | location of your Java installation."
106 | fi
107 |
108 | # Increase the maximum file descriptors if we can.
109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
110 | MAX_FD_LIMIT=`ulimit -H -n`
111 | if [ $? -eq 0 ] ; then
112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
113 | MAX_FD="$MAX_FD_LIMIT"
114 | fi
115 | ulimit -n $MAX_FD
116 | if [ $? -ne 0 ] ; then
117 | warn "Could not set maximum file descriptor limit: $MAX_FD"
118 | fi
119 | else
120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
121 | fi
122 | fi
123 |
124 | # For Darwin, add options to specify how the application appears in the dock
125 | if $darwin; then
126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
127 | fi
128 |
129 | # For Cygwin or MSYS, switch paths to Windows format before running java
130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
133 |
134 | JAVACMD=`cygpath --unix "$JAVACMD"`
135 |
136 | # We build the pattern for arguments to be converted via cygpath
137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
138 | SEP=""
139 | for dir in $ROOTDIRSRAW ; do
140 | ROOTDIRS="$ROOTDIRS$SEP$dir"
141 | SEP="|"
142 | done
143 | OURCYGPATTERN="(^($ROOTDIRS))"
144 | # Add a user-defined pattern to the cygpath arguments
145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
147 | fi
148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
149 | i=0
150 | for arg in "$@" ; do
151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
153 |
154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
156 | else
157 | eval `echo args$i`="\"$arg\""
158 | fi
159 | i=`expr $i + 1`
160 | done
161 | case $i in
162 | 0) set -- ;;
163 | 1) set -- "$args0" ;;
164 | 2) set -- "$args0" "$args1" ;;
165 | 3) set -- "$args0" "$args1" "$args2" ;;
166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
172 | esac
173 | fi
174 |
175 | # Escape application args
176 | save () {
177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
178 | echo " "
179 | }
180 | APP_ARGS=`save "$@"`
181 |
182 | # Collect all arguments for the java command, following the shell quoting and substitution rules
183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
184 |
185 | exec "$JAVACMD" "$@"
186 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/uol/pagbank/plugpagservice/demo/ui/nfc/NFCFragment.kt:
--------------------------------------------------------------------------------
1 | package br.com.uol.pagbank.plugpagservice.demo.ui.nfc
2 |
3 | import android.os.Bundle
4 | import android.view.LayoutInflater
5 | import android.view.View
6 | import android.view.ViewGroup
7 | import android.widget.Button
8 | import android.widget.TextView
9 | import androidx.fragment.app.Fragment
10 | import androidx.lifecycle.ViewModelProvider
11 | import br.com.uol.pagbank.plugpagservice.demo.databinding.FragmentNfcBinding
12 | import br.com.uol.pagbank.plugpagservice.demo.extensions.getIn
13 | import br.com.uol.pagbank.plugpagservice.demo.extensions.getOut
14 | import kotlinx.coroutines.CoroutineScope
15 | import kotlinx.coroutines.Dispatchers
16 | import kotlinx.coroutines.launch
17 |
18 | class NFCFragment : Fragment() {
19 | private var _binding: FragmentNfcBinding? = null
20 | private val binding get() = _binding!!
21 |
22 | private lateinit var nfcViewModel: NFCViewModel
23 |
24 | private val coroutineScope = CoroutineScope(Dispatchers.IO)
25 | private val buttons = mutableListOf