Skip to content

Commit

Permalink
Fix multiple bugs
Browse files Browse the repository at this point in the history
+ Replace Eclipse logo by Calypso
+ Clean code
+ Update Coppernic flavor name

Signed-off-by: Youssef Amrani <youssef.amrani@yamapps.fr>
  • Loading branch information
Yamapps committed Jun 11, 2021
1 parent 8749871 commit 3d417e7
Show file tree
Hide file tree
Showing 26 changed files with 481 additions and 850 deletions.
100 changes: 86 additions & 14 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,17 +1,89 @@
# Built application files
*.apk
*.aar
*.ap_
*.aab

# Files for the ART/Dalvik VM
*.dex

# Java class files
*.class

# Generated files
bin/
gen/
out/
# Uncomment the following line in case you need and you don't have the release build type files in your app
# release/

# Gradle files
.gradle/
build/

# Local configuration file (sdk path, etc)
local.properties

# Proguard folder generated by Eclipse
proguard/

# Log Files
*.log

# Android Studio Navigation editor temp files
.navigation/

# Android Studio captures folder
captures/

# IntelliJ
*.iml
.gradle
/local.properties
/.idea
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/*/build/
/*/*.iml
/captures
.idea/workspace.xml
.idea/tasks.xml
.idea/gradle.xml
.idea/assetWizardSettings.xml
.idea/dictionaries
.idea/libraries
# Android Studio 3 in .gitignore file.
.idea/caches
.idea/modules.xml
# Comment next line if keeping position of elements in Navigation Editor is relevant for you
.idea/navEditor.xml

# Keystore files
# Uncomment the following lines if you do not want to check your keystore files in.
#*.jks
#*.keystore

# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild
.cxx
.cxx/

# Google Services (e.g. APIs or Firebase)
# google-services.json

# Freeline
freeline.py
freeline/
freeline_project_description.json

# fastlane
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
fastlane/readme.md

# Version control
vcs.xml

# lint
lint/intermediates/
lint/generated/
lint/outputs/
lint/tmp/
# lint/reports/

# Android Profiling
*.hprof
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ object DateUtils {
const val DATE_01_01_1997 = "01/01/1997"
const val DATE_01_01_2010 = "01/01/2010"
const val DD_MM_YYYY = "dd/MM/yyyy"
const val DATE_FORMAT_DISPLAY = "dd/MM/yyyy, HH:mm"
const val DATE_FORMAT_DISPLAY = "dd MMMM yyyy, HH:mm"

const val MILLIS_PER_DAY = 1000 * 60 * 60 * 24
const val MILLIS_PER_MINUTE = 60 * 24
Expand Down
10 changes: 5 additions & 5 deletions validator-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ android {
resValue "string", "app_name", "Keyple Validation OMAPI"
applicationIdSuffix ".omapi"
}
copernic {
coppernic {
dimension 'device'
resValue "string", "app_name", "Keyple Validation Copernic"
applicationIdSuffix ".copernic"
resValue "string", "app_name", "Keyple Validation coppernic"
applicationIdSuffix ".coppernic"
}
famoco {
dimension 'device'
Expand All @@ -81,7 +81,7 @@ android {
test.java.srcDirs += 'src/test/kotlin'

omapi.java.srcDirs += 'src/omapi/kotlin'
copernic.java.srcDirs += 'src/copernic/kotlin'
coppernic.java.srcDirs += 'src/coppernic/kotlin'
famoco.java.srcDirs += 'src/famoco/kotlin'
mockSam.java.srcDirs += 'src/mockSam/kotlin'
bluebird.java.srcDirs += 'src/bluebird/kotlin'
Expand Down Expand Up @@ -115,7 +115,7 @@ dependencies {

mockSamImplementation "org.eclipse.keyple:keyple-android-plugin-nfc:$keyple_version"

copernicImplementation "org.eclipse.keyple:keyple-android-plugin-coppernic-ask:$coppernic_plugin_version"
coppernicImplementation "org.eclipse.keyple:keyple-android-plugin-coppernic-ask:$coppernic_plugin_version"

bluebirdImplementation "org.eclipse.keyple:keyple-android-plugin-bluebird:$bluebird_plugin_version"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
package org.eclipse.keyple.demo.validator.data

import android.app.Activity
import javax.inject.Inject
import org.eclipse.keyple.core.service.Reader
import org.eclipse.keyple.core.service.SmartCardService
import org.eclipse.keyple.core.service.event.ObservableReader
Expand All @@ -22,15 +21,15 @@ import org.eclipse.keyple.core.service.exception.KeyplePluginNotFoundException
import org.eclipse.keyple.core.service.exception.KeypleReaderIOException
import org.eclipse.keyple.demo.validator.di.scopes.AppScoped
import org.eclipse.keyple.demo.validator.reader.IReaderRepository
import org.eclipse.keyple.demo.validator.ticketing.ITicketingSession
import org.eclipse.keyple.demo.validator.ticketing.TicketingSession
import org.eclipse.keyple.demo.validator.ticketing.TicketingSessionManager
import timber.log.Timber
import javax.inject.Inject

@AppScoped
class CardReaderApi @Inject constructor(private var readerRepository: IReaderRepository) {

private lateinit var ticketingSessionManager: TicketingSessionManager
private var ticketingSession: TicketingSession? = null
private var ticketingSession: ITicketingSession? = null

@Throws(
KeyplePluginInstantiationException::class,
Expand Down Expand Up @@ -83,10 +82,7 @@ class CardReaderApi @Inject constructor(private var readerRepository: IReaderRep
/* remove the observer if it already exist */
(reader as ObservableReader).addObserver(observer)

ticketingSessionManager = TicketingSessionManager()

ticketingSession =
ticketingSessionManager.createTicketingSession(readerRepository) as TicketingSession
ticketingSession = TicketingSession(readerRepository)
}
}

Expand All @@ -109,7 +105,7 @@ class CardReaderApi @Inject constructor(private var readerRepository: IReaderRep
}
}

fun getTicketingSession(): TicketingSession? {
fun getTicketingSession(): ITicketingSession? {
return ticketingSession
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ import com.google.gson.Gson
import com.google.gson.GsonBuilder
import org.eclipse.keyple.demo.validator.models.Location
import org.eclipse.keyple.demo.validator.util.FileHelper
import timber.log.Timber
import java.io.BufferedReader
import java.io.File
import java.io.FileInputStream
import java.io.FileNotFoundException
import java.io.IOException
import java.io.InputStream
import java.io.InputStreamReader
Expand Down Expand Up @@ -62,12 +64,18 @@ class LocationFileManager @Inject constructor(context: Context) {
)
}
}

fun getLocations(): List<Location> {
if (locationList == null) {
val file = getFileFromSdCard()
locationList = getGson().fromJson(file, Array<Location>::class.java).toList()
try{
val file = getFileFromSdCard()
locationList = getGson().fromJson(file, Array<Location>::class.java).toList()
}
catch (e: FileNotFoundException){
Timber.e(e)
locationList = getGson().fromJson(locationsFromResources, Array<Location>::class.java).toList()
}
}

return locationList!!
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ class EnvironmentException(key: EnvironmentExceptionKey) :
ValidationException(key.value)

enum class EnvironmentExceptionKey constructor(val key: Int, val value: String) {
WRONG_VERSION_NUMBER(0, "Environment Error : wrong version number"),
EXPIRED(1, "Environment Error : end date expired");
WRONG_VERSION_NUMBER(0, "Environment Error: wrong version number"),
EXPIRED(1, "Environment Error: end date expired");
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ class EventException(key: EventExceptionKey) : ValidationException(key.value)

enum class EventExceptionKey constructor(val key: Int, val value: String) {
WRONG_VERSION_NUMBER(0, "Event - Wrong version number"),
CLEAN_CARD(1, "No valid title detected");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright (c) 2021 Calypso Networks Association https://www.calypsonet-asso.org/
*
* See the NOTICE file(s) distributed with this work for additional information
* regarding copyright ownership.
*
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/

package org.eclipse.keyple.demo.validator.models

enum class StructureEnum(val key: Int) {
STRUCTURE_05H(0x5),
STRUCTURE_13H(0x13),
STRUCTURE_32H(0x32),
STRUCTURE_42H(0x42);

override fun toString(): String {
return "Structure ${Integer.toHexString(key)}h"
}


companion object {
fun findEnumByKey(key : Int): StructureEnum? {
val values = values()
return values.find {
it.key == key
}
}
}

}
Loading

0 comments on commit 3d417e7

Please sign in to comment.