Update the Tags app to the holo theme and fix some bugs.

Change-Id: I217cf3f5b2e228df50ff1bed050448bf72140a3b
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 9b4115f..dac0d4f 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -33,7 +33,7 @@
         android:label="@string/app_name"
     >
         <activity android:name="TagViewer"
-            android:theme="@android:style/Theme.NoTitleBar"
+            android:label="@string/title_scanned_tag"
             android:launchMode="singleTop"
             android:priority="-10"
         >
diff --git a/res/layout/tag_viewer.xml b/res/layout/tag_viewer.xml
index 7a7f917..0370b53 100644
--- a/res/layout/tag_viewer.xml
+++ b/res/layout/tag_viewer.xml
@@ -20,41 +20,6 @@
 
     android:orientation="vertical"
 >
-    <!-- Title -->
-
-    <LinearLayout
-        android:layout_width="match_parent"
-        android:layout_height="65dip"
-
-        android:orientation="horizontal"
-        android:background="@drawable/title_bar_medium"
-    >
-
-        <ImageView android:id="@+id/icon"
-            android:layout_width="32dip"
-            android:layout_height="32dip"
-            android:layout_centerVertical="true"
-            android:layout_marginRight="4dip"
-
-            android:src="@drawable/ic_launcher_nfc"
-        />
-
-        <TextView android:id="@+id/title"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_centerVertical="true"
-            android:layout_marginLeft="8dip"
-
-            android:singleLine="true"
-            android:textAppearance="?android:attr/textAppearanceMedium"
-            android:textStyle="bold"
-            android:shadowColor="#BB000000"
-            android:shadowRadius="2.75"
-            
-            android:text="@string/title_scanned_tag"
-        />
-    </LinearLayout>
-
     <!-- Content -->
 
     <ScrollView
@@ -73,7 +38,7 @@
     </ScrollView>
 
     <!-- Bottom button area -->
-
+<!--
     <LinearLayout
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
@@ -91,5 +56,5 @@
         />
 
     </LinearLayout>
-
+-->
 </LinearLayout>
\ No newline at end of file
diff --git a/src/com/android/apps/tag/TagViewer.java b/src/com/android/apps/tag/TagViewer.java
index 14e58f8..b4e9474 100644
--- a/src/com/android/apps/tag/TagViewer.java
+++ b/src/com/android/apps/tag/TagViewer.java
@@ -22,7 +22,6 @@
 
 import android.app.Activity;
 import android.content.Intent;
-import android.net.Uri;
 import android.nfc.NdefMessage;
 import android.nfc.NdefRecord;
 import android.nfc.NfcAdapter;
@@ -32,8 +31,8 @@
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.View.OnClickListener;
-import android.widget.Button;
 import android.widget.LinearLayout;
+import android.widget.TextView;
 
 import java.util.List;
 
@@ -52,7 +51,6 @@
         setContentView(R.layout.tag_viewer);
 
         mTagContent = (LinearLayout) findViewById(R.id.list);
-        findViewById(R.id.button_done).setOnClickListener(this);
 
         resolveIntent(getIntent());
     }
@@ -62,25 +60,13 @@
         String action = intent.getAction();
         if (NfcAdapter.ACTION_TAG_DISCOVERED.equals(action)
                 || NfcAdapter.ACTION_TECH_DISCOVERED.equals(action)) {
-            // When a tag is discovered we send it to the service to be save. We
-            // include a PendingIntent for the service to call back onto. This
-            // will cause this activity to be restarted with onNewIntent(). At
-            // that time we read it from the database and view it.
             Parcelable[] rawMsgs = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
-            NdefMessage[] msgs;
+            NdefMessage msg = null;
             if (rawMsgs != null && rawMsgs.length > 0) {
-                // stupid java, need to cast one-by-one
-                msgs = new NdefMessage[rawMsgs.length];
-                for (int i = 0; i < rawMsgs.length; i++) {
-                    msgs[i] = (NdefMessage) rawMsgs[i];
-                }
-            } else {
-                // Unknown tag type
-                byte[] empty = new byte[] {};
-                NdefRecord record = new NdefRecord(NdefRecord.TNF_UNKNOWN, empty, empty, empty);
-                NdefMessage msg = new NdefMessage(new NdefRecord[] { record });
-                msgs = new NdefMessage[] { msg };
+                msg = (NdefMessage) rawMsgs[0];
             }
+
+            buildTagViews(msg);
         } else {
             Log.e(TAG, "Unknown intent " + intent);
             finish();
@@ -89,28 +75,35 @@
     }
 
     void buildTagViews(NdefMessage msg) {
-        if (msg == null) {
-            return;
-        }
-
         LayoutInflater inflater = LayoutInflater.from(this);
         LinearLayout content = mTagContent;
 
         // Clear out any old views in the content area, for example if you scan two tags in a row.
         content.removeAllViews();
 
-        // Parse the first message in the list
-        //TODO figure out what to do when/if we support multiple messages per tag
-        ParsedNdefMessage parsedMsg = NdefMessageParser.parse(msg);
-
         // Build views for all of the sub records
-        List<ParsedNdefRecord> records = parsedMsg.getRecords();
-        final int size = records.size();
+        if (msg == null) {
+            TextView empty = (TextView) inflater.inflate(R.layout.tag_text, content, false);
+            empty.setText(R.string.tag_empty);
+            content.addView(empty);
+        } else {
+            // Parse the first message in the list
+            //TODO figure out what to do when/if we support multiple messages per tag
+            ParsedNdefMessage parsedMsg = NdefMessageParser.parse(msg);
 
-        for (int i = 0; i < size; i++) {
-            ParsedNdefRecord record = records.get(i);
-            content.addView(record.getView(this, inflater, content, i));
-            inflater.inflate(R.layout.tag_divider, content, true);
+            List<ParsedNdefRecord> records = parsedMsg.getRecords();
+            final int size = records.size();
+            if (size == 0) {
+                TextView empty = (TextView) inflater.inflate(R.layout.tag_text, content, false);
+                empty.setText(R.string.tag_empty);
+                content.addView(empty);
+            } else {
+                for (int i = 0; i < size; i++) {
+                    ParsedNdefRecord record = records.get(i);
+                    content.addView(record.getView(this, inflater, content, i));
+                    inflater.inflate(R.layout.tag_divider, content, true);
+                }
+            }
         }
     }