Permalink
Browse files

first commit

  • Loading branch information...
0 parents commit 65eb1178c529fbc03a2e1cdbd2f7c949bded1344 @nadam committed Nov 14, 2011
@@ -0,0 +1,6 @@
+proguard.cfg
+.classpath
+default.properties
+bin/
+gen/
+*.DS_Store
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>nfc-reader</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ApkBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="se.anyro.nfc_reader"
+ android:versionCode="8"
+ android:versionName="0.8"
+ android:installLocation="auto">
+
+ <uses-sdk android:minSdkVersion="9" android:targetSdkVersion="10" />
+
+ <uses-permission android:name="android.permission.NFC" />
+ <uses-feature android:name="android.hardware.nfc" />
+
+ <application
+ android:icon="@drawable/icon"
+ android:label="@string/app_name">
+ <activity
+ android:name="TagViewer"
+ android:label="@string/app_name"
+ android:screenOrientation="nosensor"
+ android:alwaysRetainTaskState="true"
+ android:launchMode="singleInstance">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ <intent-filter>
+ <action android:name="android.nfc.action.TAG_DISCOVERED"/>
+ <category android:name="android.intent.category.DEFAULT"/>
+ </intent-filter>
+ </activity>
+ </application>
+
+</manifest>
4 README
@@ -0,0 +1,4 @@
+Simple NFC reader for Android based on the sample code from the Android SDK.
+
+The app is available on Android Market.
+https://market.android.com/details?id=se.anyro.nfc_reader
@@ -0,0 +1,11 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system use,
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+
+# Project target.
+target=Google Inc.:Google APIs:10
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2010 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<View xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:background="?android:attr/listDivider"
+/>
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2010 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/text"
+ android:layout_width="match_parent"
+ android:minHeight="?android:attr/listPreferredItemHeight"
+ android:layout_height="wrap_content"
+ android:padding="4dip"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:ellipsize="end"
+ android:gravity="center_vertical"
+/>
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2010 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+ <ScrollView
+ android:layout_width="match_parent"
+ android:layout_height="0dip"
+ android:layout_weight="1">
+ <LinearLayout
+ android:id="@+id/list"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
+ <TextView
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/intro_message" />
+ </LinearLayout>
+ </ScrollView>
+</LinearLayout>
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2011 Adam Nybäck
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<resources>
+ <string name="app_name">NFC Reader</string>
+ <string name="intro_message">This is just a test app to read and display various tags (NDEF, RFID, FeliCa, ISO 14443, etc).\n\nPlease let me know if you want me to change how the data is displayed. Also send me an e-mail (adam@anyro.se) if you have problem with this app and I\'ll let you know when I\'ve fixed it. Thanks!</string>
+</resources>
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package se.anyro.nfc_reader;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import se.anyro.nfc_reader.record.ParsedNdefRecord;
+import se.anyro.nfc_reader.record.SmartPoster;
+import se.anyro.nfc_reader.record.TextRecord;
+import se.anyro.nfc_reader.record.UriRecord;
+import android.app.Activity;
+import android.nfc.NdefMessage;
+import android.nfc.NdefRecord;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+/**
+ * Utility class for creating {@link ParsedNdefMessage}s.
+ */
+public class NdefMessageParser {
+
+ // Utility class
+ private NdefMessageParser() {
+
+ }
+
+ /** Parse an NdefMessage */
+ public static List<ParsedNdefRecord> parse(NdefMessage message) {
+ return getRecords(message.getRecords());
+ }
+
+ public static List<ParsedNdefRecord> getRecords(NdefRecord[] records) {
+ List<ParsedNdefRecord> elements = new ArrayList<ParsedNdefRecord>();
+ for (final NdefRecord record : records) {
+ if (UriRecord.isUri(record)) {
+ elements.add(UriRecord.parse(record));
+ } else if (TextRecord.isText(record)) {
+ elements.add(TextRecord.parse(record));
+ } else if (SmartPoster.isPoster(record)) {
+ elements.add(SmartPoster.parse(record));
+ } else {
+ elements.add(new ParsedNdefRecord() {
+ @Override
+ public View getView(Activity activity, LayoutInflater inflater, ViewGroup parent, int offset) {
+ TextView text = (TextView) inflater.inflate(R.layout.tag_text, parent, false);
+ text.setText(new String(record.getPayload()));
+ return text;
+ }
+
+ });
+ }
+ }
+ return elements;
+ }
+}
Oops, something went wrong.

0 comments on commit 65eb117

Please sign in to comment.