From 900abe0db57aaa80e287568e4e9cd21184e4fcd2 Mon Sep 17 00:00:00 2001 From: Michele Balistreri Date: Fri, 1 Nov 2019 10:59:54 +0300 Subject: [PATCH] move constants to own file --- .../keycard/connect/card/CardScriptExecutor.kt | 2 -- .../java/im/status/keycard/connect/data/Constants.kt | 12 ++++++++++++ .../im/status/keycard/connect/data/PairingManager.kt | 1 - .../im/status/keycard/connect/ui/InitActivity.kt | 8 +++----- .../im/status/keycard/connect/ui/MainActivity.kt | 1 + .../java/im/status/keycard/connect/ui/PINActivity.kt | 5 ++--- .../im/status/keycard/connect/ui/PairingActivity.kt | 8 ++------ 7 files changed, 20 insertions(+), 17 deletions(-) create mode 100644 app/src/main/java/im/status/keycard/connect/data/Constants.kt diff --git a/app/src/main/java/im/status/keycard/connect/card/CardScriptExecutor.kt b/app/src/main/java/im/status/keycard/connect/card/CardScriptExecutor.kt index 40bfbd8..faf4acf 100644 --- a/app/src/main/java/im/status/keycard/connect/card/CardScriptExecutor.kt +++ b/app/src/main/java/im/status/keycard/connect/card/CardScriptExecutor.kt @@ -7,8 +7,6 @@ import im.status.keycard.io.CardChannel import im.status.keycard.io.CardListener import java.util.* -const val REQ_INTERACTIVE_SCRIPT = 0x01 - class CardScriptExecutor(activity: Activity) : CardListener { class Context(val mainActivity: Activity) { var cardChannel: CardChannel? = null diff --git a/app/src/main/java/im/status/keycard/connect/data/Constants.kt b/app/src/main/java/im/status/keycard/connect/data/Constants.kt new file mode 100644 index 0000000..80efc94 --- /dev/null +++ b/app/src/main/java/im/status/keycard/connect/data/Constants.kt @@ -0,0 +1,12 @@ +package im.status.keycard.connect.data + +const val PAIRING_ACTIVITY_PASSWORD = "pairingPassword" + +const val PIN_ACTIVITY_ATTEMPTS = "remainingAttempts" +const val PIN_ACTIVITY_CARD_UID = "cardUID" + +const val INIT_ACTIVITY_PIN = "initPIN" +const val INIT_ACTIVITY_PUK = "initPUK" +const val INIT_ACTIVITY_PAIRING = "initPairing" + +const val REQ_INTERACTIVE_SCRIPT = 0x01 diff --git a/app/src/main/java/im/status/keycard/connect/data/PairingManager.kt b/app/src/main/java/im/status/keycard/connect/data/PairingManager.kt index cad1b6a..6ed305e 100644 --- a/app/src/main/java/im/status/keycard/connect/data/PairingManager.kt +++ b/app/src/main/java/im/status/keycard/connect/data/PairingManager.kt @@ -9,7 +9,6 @@ import im.status.keycard.applet.Pairing import androidx.security.crypto.EncryptedSharedPreferences import androidx.security.crypto.MasterKeys - object PairingManager { private lateinit var sharedPreferences: SharedPreferences diff --git a/app/src/main/java/im/status/keycard/connect/ui/InitActivity.kt b/app/src/main/java/im/status/keycard/connect/ui/InitActivity.kt index 44bf5bd..c6259cc 100644 --- a/app/src/main/java/im/status/keycard/connect/ui/InitActivity.kt +++ b/app/src/main/java/im/status/keycard/connect/ui/InitActivity.kt @@ -11,11 +11,9 @@ import android.util.Base64.NO_PADDING import android.util.Base64.NO_WRAP import android.widget.TextView import im.status.keycard.connect.R - - -const val INIT_ACTIVITY_PIN = "initPIN" -const val INIT_ACTIVITY_PUK = "initPUK" -const val INIT_ACTIVITY_PAIRING = "initPairing" +import im.status.keycard.connect.data.INIT_ACTIVITY_PAIRING +import im.status.keycard.connect.data.INIT_ACTIVITY_PIN +import im.status.keycard.connect.data.INIT_ACTIVITY_PUK class InitActivity : AppCompatActivity() { private lateinit var pin: String diff --git a/app/src/main/java/im/status/keycard/connect/ui/MainActivity.kt b/app/src/main/java/im/status/keycard/connect/ui/MainActivity.kt index 48d776b..8c19ef1 100644 --- a/app/src/main/java/im/status/keycard/connect/ui/MainActivity.kt +++ b/app/src/main/java/im/status/keycard/connect/ui/MainActivity.kt @@ -8,6 +8,7 @@ import android.content.Intent import im.status.keycard.connect.R import im.status.keycard.connect.card.* import im.status.keycard.connect.data.PairingManager +import im.status.keycard.connect.data.REQ_INTERACTIVE_SCRIPT class MainActivity : AppCompatActivity() { private lateinit var cardManager: NFCCardManager diff --git a/app/src/main/java/im/status/keycard/connect/ui/PINActivity.kt b/app/src/main/java/im/status/keycard/connect/ui/PINActivity.kt index 9ba8077..8908d2a 100644 --- a/app/src/main/java/im/status/keycard/connect/ui/PINActivity.kt +++ b/app/src/main/java/im/status/keycard/connect/ui/PINActivity.kt @@ -8,9 +8,8 @@ import android.widget.EditText import android.widget.TextView import im.status.keycard.connect.R import im.status.keycard.connect.data.PINCache - -const val PIN_ACTIVITY_ATTEMPTS = "remainingAttempts" -const val PIN_ACTIVITY_CARD_UID = "cardUID" +import im.status.keycard.connect.data.PIN_ACTIVITY_ATTEMPTS +import im.status.keycard.connect.data.PIN_ACTIVITY_CARD_UID class PINActivity : AppCompatActivity() { private lateinit var cardUID: ByteArray diff --git a/app/src/main/java/im/status/keycard/connect/ui/PairingActivity.kt b/app/src/main/java/im/status/keycard/connect/ui/PairingActivity.kt index 24a45f7..399ead0 100644 --- a/app/src/main/java/im/status/keycard/connect/ui/PairingActivity.kt +++ b/app/src/main/java/im/status/keycard/connect/ui/PairingActivity.kt @@ -7,8 +7,7 @@ import android.view.View import android.widget.EditText import android.content.Intent import im.status.keycard.connect.R - -const val PAIRING_ACTIVITY_PASSWORD = "pairingPassword" +import im.status.keycard.connect.data.PAIRING_ACTIVITY_PASSWORD class PairingActivity : AppCompatActivity() { @@ -19,10 +18,7 @@ class PairingActivity : AppCompatActivity() { fun ok(view: View) { val intent = Intent() - intent.putExtra( - PAIRING_ACTIVITY_PASSWORD, findViewById( - R.id.passwordText - ).text.toString()) + intent.putExtra(PAIRING_ACTIVITY_PASSWORD, findViewById(R.id.passwordText).text.toString()) setResult(Activity.RESULT_OK, intent) finish() }