From 165405605944b43b7017510871babd33992d08fc Mon Sep 17 00:00:00 2001 From: "jihye1128.kim" Date: Fri, 16 Dec 2011 19:06:33 +0900 Subject: [PATCH] [Title] Modify NFC UI- Add restrictions [Type] Enhancement [Module] event injector nfc [Priority] Minor [CQ#] [Redmine#] [Problem] [Cause] [Solution] --- .../com/samsung/tizen/nfc/tag/page/NfcPage.java | 39 ++++++++++++++-------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/com.samsung.tizen.nfc/src/com/samsung/tizen/nfc/tag/page/NfcPage.java b/com.samsung.tizen.nfc/src/com/samsung/tizen/nfc/tag/page/NfcPage.java index 34a3236..2338204 100644 --- a/com.samsung.tizen.nfc/src/com/samsung/tizen/nfc/tag/page/NfcPage.java +++ b/com.samsung.tizen.nfc/src/com/samsung/tizen/nfc/tag/page/NfcPage.java @@ -68,6 +68,7 @@ public class NfcPage extends AbstractInjectorPage implements ISelectionListener private Label lblRecords; private int nTotalLength = 0; + private final int nMaxNDFEMessageLength = 4096; private Combo cmbRecordList; private ArrayList RecordList = new ArrayList(); @@ -142,7 +143,7 @@ public class NfcPage extends AbstractInjectorPage implements ISelectionListener Composite RecordComposite = formUtil.createComposite(messageComposite, 2); GridData gd2 = new GridData(); gd2.widthHint = 160; - lblRecords = formUtil.createLabel(RecordComposite, "Records [0/4000] "); + lblRecords = formUtil.createLabel(RecordComposite, String.format("Records [0/%d] ", nMaxNDFEMessageLength)); lblRecords.setLayoutData(gd2); cmbRecordList = formUtil.createCombo(RecordComposite); @@ -184,6 +185,11 @@ public class NfcPage extends AbstractInjectorPage implements ISelectionListener NfcDialog.openInfoDialog(shell, "Can not enter a newline character."); return false; } + + if (c == ',') { + NfcDialog.openInfoDialog(shell, "Can not enter ',' character.\nThis character is used separater character."); + return false; + } if (c >= 0x80) { NfcDialog.openInfoDialog(shell, "Invalid characters are entered.\nOnly ASCII characters can be entered.\n"); @@ -229,6 +235,7 @@ public class NfcPage extends AbstractInjectorPage implements ISelectionListener txtRecordTypeName = formUtil.createText(messageComposite, ""); txtRecordTypeName.setEnabled(false); txtRecordTypeName.setLayoutData(gd1); + txtRecordTypeName.setTextLimit(250); txtRecordTypeName.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { if (bCheckTypeNameText == false) { @@ -255,6 +262,7 @@ public class NfcPage extends AbstractInjectorPage implements ISelectionListener txtRecordID = formUtil.createText(messageComposite, ""); txtRecordID.setEnabled(false); txtRecordID.setLayoutData(gd1); + txtRecordID.setTextLimit(250); txtRecordID.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { if (bCheckIDText == false) { @@ -275,7 +283,7 @@ public class NfcPage extends AbstractInjectorPage implements ISelectionListener txtRecordPayload = formUtil.createText(messageComposite, ""); txtRecordPayload.setEnabled(false); txtRecordPayload.setLayoutData(gd1); - txtRecordPayload.setTextLimit(1000); + txtRecordPayload.setTextLimit(1024); txtRecordPayload.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { if (bCheckPayloadText == false) { @@ -446,12 +454,14 @@ public class NfcPage extends AbstractInjectorPage implements ISelectionListener NDEFRecord record = new NDEFRecord(); + /* // check duplicate id !! if (cmbRecordFormat.getSelectionIndex() != 0) { if (!checkRecordID(txtRecordID.getText() != null ? txtRecordID.getText() : "Null")) { return; } } + */ setRecordValue(record); RecordList.add(record); @@ -460,7 +470,7 @@ public class NfcPage extends AbstractInjectorPage implements ISelectionListener return; } - lblRecords.setText(String.format("Records [%4d/4000] ", nTotalLength)); + lblRecords.setText(String.format("Records [%4d/%d] ", nTotalLength, nMaxNDFEMessageLength)); cmbRecordList.add("record item" + RecordList.indexOf(record)); cmbRecordList.clearSelection(); } @@ -470,12 +480,14 @@ public class NfcPage extends AbstractInjectorPage implements ISelectionListener int i = cmbRecordList.getSelectionIndex(); if (i != -1) { NDEFRecord record = RecordList.get(i); + /* + // check duplicate id !! if (record.getFormat() != 0) { - // check duplicate id !! if (!checkRecordID(txtRecordID.getText() != null ? txtRecordID.getText() : "Null", i)) { return; } } + */ NDEFRecord copyRecord = record; setRecordValue(record); @@ -485,7 +497,7 @@ public class NfcPage extends AbstractInjectorPage implements ISelectionListener return; } - lblRecords.setText(String.format("Records [%4d/4000] ", nTotalLength)); + lblRecords.setText(String.format("Records [%4d/%d] ", nTotalLength, nMaxNDFEMessageLength)); // cmbRecordFormat.select(record.getFormat()); // checkFormat(record.getFormat()); } @@ -504,7 +516,7 @@ public class NfcPage extends AbstractInjectorPage implements ISelectionListener } checkRecordlistMaxLength(); - lblRecords.setText(String.format("Records [%4d/4000] ", nTotalLength)); + lblRecords.setText(String.format("Records [%4d/%d] ", nTotalLength, nMaxNDFEMessageLength)); txtRecordTypeName.setText(""); cmbRecordTypeName.select(0); txtRecordID.setText(""); @@ -534,7 +546,7 @@ public class NfcPage extends AbstractInjectorPage implements ISelectionListener else record.setPayload(txtRecordPayload.getText()); } - +/* private boolean checkRecordID(String id) { for (NDEFRecord record : RecordList) { @@ -564,22 +576,23 @@ public class NfcPage extends AbstractInjectorPage implements ISelectionListener return true; } +*/ private boolean checkRecordlistMaxLength() { - String strValue = ""; + int lenList = 0; for (NDEFRecord record : RecordList) { - strValue += record.getFormat() + record.getTypeName() - + record.getId() + record.getPayload(); + lenList += 1 + record.getTypeName().length() + + record.getId().length() + record.getPayload().length() + 4; } - if (strValue.length() > 4000) { - NfcDialog.openInfoDialog(shell, "The length of the NDEF message has reached the maxium limit of 4,000 bytes\n"); + if (lenList > nMaxNDFEMessageLength) { + NfcDialog.openInfoDialog(shell, String.format("The length of the NDEF message has reached the maxium limit of %d bytes\n", nMaxNDFEMessageLength)); return false; } - nTotalLength = strValue.length(); + nTotalLength = lenList; return true; } -- 2.7.4