add compatible mode; fix strings

master
wlt233 2 years ago
parent 8029450f73
commit 4ffdfce27d

@ -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)

@ -5,6 +5,9 @@
<item <item
android:id="@+id/toolbar_menu_hide_id" android:id="@+id/toolbar_menu_hide_id"
android:title="@string/show_idm" /> android:title="@string/show_idm" />
<item
android:id="@+id/toolbar_menu_compatible"
android:title="@string/compatible_on" />
<item <item
android:id="@+id/toolbar_menu_settings" android:id="@+id/toolbar_menu_settings"
android:title="@string/settings" /> android:title="@string/settings" />

@ -7,4 +7,8 @@
<string name="show_idm">展示卡号</string> <string name="show_idm">展示卡号</string>
<string name="hide_idm">隐藏卡号</string> <string name="hide_idm">隐藏卡号</string>
<string name="error">出错了!</string> <string name="error">出错了!</string>
<string name="compatible_on">打开兼容模式</string>
<string name="compatible_off">关闭兼容模式</string>
<string name="nfc_not_on">NFC 没开...</string>
<string name="nfc_not_supported">设备不支持 NFC...</string>
</resources> </resources>

@ -4,11 +4,15 @@
<string name="delete">Delete</string> <string name="delete">Delete</string>
<string name="show_idm">Show IDm</string> <string name="show_idm">Show IDm</string>
<string name="hide_idm">Hide IDm</string> <string name="hide_idm">Hide IDm</string>
<string name="compatible_on">Compatible mode on</string>
<string name="compatible_off">Compatible mode off</string>
<string name="settings">Settings</string> <string name="settings">Settings</string>
<string name="error">Error!</string> <string name="error">Error!</string>
<string name="dummy_card_name">AIC Card</string> <string name="dummy_card_name">AIC Card</string>
<string name="dummy_card_id" translatable="false">012EXXXXXXXXXXXX</string> <string name="dummy_card_id" translatable="false">012EXXXXXXXXXXXX</string>
<string name="read_card_tip">Please touch your AIC Card!</string> <string name="read_card_tip">Please touch your AIC Card!</string>
<string name="nfc_not_supported">NFC not supported</string>
<string name="nfc_not_on">NFC is off...</string>
<string name="desc_add_card" translatable="false">add card</string> <string name="desc_add_card" translatable="false">add card</string>
<string name="desc_edit_card" translatable="false">edit card</string> <string name="desc_edit_card" translatable="false">edit card</string>
<string name="desc_close_popup" translatable="false">close</string> <string name="desc_close_popup" translatable="false">close</string>

Loading…
Cancel
Save