|
|
@ -34,11 +34,12 @@ class MainActivity : AppCompatActivity() {
|
|
|
|
private var nfcAdapter: NfcAdapter? = null
|
|
|
|
private var nfcAdapter: NfcAdapter? = null
|
|
|
|
private var nfcFCardEmulation: NfcFCardEmulation? = null
|
|
|
|
private var nfcFCardEmulation: NfcFCardEmulation? = null
|
|
|
|
private var nfcPendingIntent: PendingIntent? = null
|
|
|
|
private var nfcPendingIntent: PendingIntent? = null
|
|
|
|
private val gson = Gson()
|
|
|
|
|
|
|
|
private var cards = mutableListOf<Card>()
|
|
|
|
private var cards = mutableListOf<Card>()
|
|
|
|
|
|
|
|
private val gson = Gson()
|
|
|
|
private val cardsJsonPath = "card.json"
|
|
|
|
private val cardsJsonPath = "card.json"
|
|
|
|
private var showCardID: Boolean = false
|
|
|
|
|
|
|
|
private val TAG = "AICEmu"
|
|
|
|
private val TAG = "AICEmu"
|
|
|
|
|
|
|
|
private var showCardID: Boolean = false
|
|
|
|
|
|
|
|
private var compatibleID: Boolean = false
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
@ -69,13 +70,13 @@ class MainActivity : AppCompatActivity() {
|
|
|
|
if (nfcAdapter == null) {
|
|
|
|
if (nfcAdapter == null) {
|
|
|
|
Log.e(TAG, "NFC not supported")
|
|
|
|
Log.e(TAG, "NFC not supported")
|
|
|
|
AlertDialog.Builder(this)
|
|
|
|
AlertDialog.Builder(this)
|
|
|
|
.setTitle(R.string.error).setMessage("NFC not supported").setCancelable(false).show()
|
|
|
|
.setTitle(R.string.error).setMessage(R.string.nfc_not_supported).setCancelable(false).show()
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!nfcAdapter!!.isEnabled) {
|
|
|
|
if (!nfcAdapter!!.isEnabled) {
|
|
|
|
Log.e(TAG, "NFC is off")
|
|
|
|
Log.e(TAG, "NFC is off")
|
|
|
|
AlertDialog.Builder(this)
|
|
|
|
AlertDialog.Builder(this)
|
|
|
|
.setTitle(R.string.error).setMessage("NFC is off").setCancelable(false).show()
|
|
|
|
.setTitle(R.string.error).setMessage(R.string.nfc_not_on).setCancelable(false).show()
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -126,15 +127,25 @@ class MainActivity : AppCompatActivity() {
|
|
|
|
return when (item.itemId) {
|
|
|
|
return when (item.itemId) {
|
|
|
|
R.id.toolbar_menu_hide_id -> {
|
|
|
|
R.id.toolbar_menu_hide_id -> {
|
|
|
|
showCardID = !showCardID
|
|
|
|
showCardID = !showCardID
|
|
|
|
item.title = if (showCardID) {
|
|
|
|
item.setTitle(if (showCardID) {
|
|
|
|
"Hide IDm"
|
|
|
|
R.string.hide_idm
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
"Show IDm"
|
|
|
|
R.string.show_idm
|
|
|
|
}
|
|
|
|
})
|
|
|
|
checkCardIDShadow()
|
|
|
|
checkCardIDShadow()
|
|
|
|
true
|
|
|
|
true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
R.id.toolbar_menu_compatible -> {
|
|
|
|
|
|
|
|
compatibleID = !compatibleID
|
|
|
|
|
|
|
|
item.setTitle(if (compatibleID) {
|
|
|
|
|
|
|
|
R.string.compatible_off
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
R.string.compatible_on
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
true
|
|
|
|
|
|
|
|
}
|
|
|
|
R.id.toolbar_menu_settings -> {
|
|
|
|
R.id.toolbar_menu_settings -> {
|
|
|
|
Toast.makeText(applicationContext, "还没做()\nUnder constuction...", Toast.LENGTH_LONG).show()
|
|
|
|
Toast.makeText(applicationContext, "还没做()\nUnder constuction...", Toast.LENGTH_LONG).show()
|
|
|
|
// TODO
|
|
|
|
// TODO
|
|
|
@ -218,8 +229,15 @@ class MainActivity : AppCompatActivity() {
|
|
|
|
val globalVar = this.applicationContext as GlobalVar
|
|
|
|
val globalVar = this.applicationContext as GlobalVar
|
|
|
|
val cardIDmTextView = cardView.findViewById<TextView>(R.id.card_id)
|
|
|
|
val cardIDmTextView = cardView.findViewById<TextView>(R.id.card_id)
|
|
|
|
globalVar.IDm = cardIDmTextView.text.toString()
|
|
|
|
globalVar.IDm = cardIDmTextView.text.toString()
|
|
|
|
//val resultIdm = setIDm(IDm)
|
|
|
|
var resultIdm = if (compatibleID) {
|
|
|
|
val resultIdm = setIDm("02fe000000000000") // hardcoded idm for sbga
|
|
|
|
// hardcoded idm for specific model e.g. Samsung S8
|
|
|
|
|
|
|
|
// idm needs to start with 02, or syscode won't be added to polling ack
|
|
|
|
|
|
|
|
// konmai reader read this idm while sbga reader do not check this
|
|
|
|
|
|
|
|
setIDm("02fe001145141919")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
setIDm(globalVar.IDm)
|
|
|
|
|
|
|
|
}
|
|
|
|
val resultSys = setSys("88B4") // hardcoded syscode for sbga
|
|
|
|
val resultSys = setSys("88B4") // hardcoded syscode for sbga
|
|
|
|
|
|
|
|
|
|
|
|
val cardNameTextView = cardView.findViewById<TextView>(R.id.card_name)
|
|
|
|
val cardNameTextView = cardView.findViewById<TextView>(R.id.card_name)
|
|
|
|