From 8149e89466644930069887527143d20cc7c91cfc Mon Sep 17 00:00:00 2001 From: Nick Kralevich Date: Thu, 14 Oct 2010 17:04:14 -0700 Subject: [PATCH] Create a ParsedNdefMessage class with supporting implementations. Change-Id: I13a199ad01a726a30e8851a675386c34f2dfa605 --- .../src/com/android/apps/tag/NdefUtil.java | 42 +--------- .../src/com/android/apps/tag/TagAdapter.java | 32 ++------ .../src/com/android/apps/tag/TagDBHelper.java | 4 +- .../Tag/src/com/android/apps/tag/TagList.java | 4 +- .../src/com/android/apps/tag/TagViewer.java | 41 +++------- .../apps/tag/message/EmptyMessage.java | 37 +++++++++ .../apps/tag/message/NdefMessageParser.java | 76 +++++++++++++++++++ .../apps/tag/message/ParsedNdefMessage.java | 35 +++++++++ .../apps/tag/message/SmartPosterMessage.java | 48 ++++++++++++ .../android/apps/tag/message/TextMessage.java | 43 +++++++++++ .../apps/tag/message/UnknownMessage.java | 45 +++++++++++ .../android/apps/tag/message/UriMessage.java | 45 +++++++++++ .../android/apps/tag/record/SmartPoster.java | 20 +++-- .../android/apps/tag/record/TextRecord.java | 7 ++ .../android/apps/tag/record/UriRecord.java | 1 + .../com/android/apps/tag/NdefUtilTest.java | 3 +- .../com/android/apps/tag/SmartPosterTest.java | 3 +- 17 files changed, 377 insertions(+), 109 deletions(-) create mode 100644 apps/Tag/src/com/android/apps/tag/message/EmptyMessage.java create mode 100644 apps/Tag/src/com/android/apps/tag/message/NdefMessageParser.java create mode 100644 apps/Tag/src/com/android/apps/tag/message/ParsedNdefMessage.java create mode 100644 apps/Tag/src/com/android/apps/tag/message/SmartPosterMessage.java create mode 100644 apps/Tag/src/com/android/apps/tag/message/TextMessage.java create mode 100644 apps/Tag/src/com/android/apps/tag/message/UnknownMessage.java create mode 100644 apps/Tag/src/com/android/apps/tag/message/UriMessage.java diff --git a/apps/Tag/src/com/android/apps/tag/NdefUtil.java b/apps/Tag/src/com/android/apps/tag/NdefUtil.java index eec7c1918..55d52f37b 100644 --- a/apps/Tag/src/com/android/apps/tag/NdefUtil.java +++ b/apps/Tag/src/com/android/apps/tag/NdefUtil.java @@ -16,20 +16,12 @@ package com.android.apps.tag; -import com.android.apps.tag.record.ParsedNdefRecord; -import com.android.apps.tag.record.SmartPoster; -import com.android.apps.tag.record.TextRecord; -import com.android.apps.tag.record.UriRecord; -import com.google.common.collect.Iterables; -import com.google.common.primitives.Bytes; - import android.net.Uri; -import android.nfc.NdefMessage; import android.nfc.NdefRecord; +import com.google.common.primitives.Bytes; + import java.nio.charset.Charsets; -import java.util.ArrayList; -import java.util.List; /** * Utilities for dealing with conversions to and from NdefRecords. @@ -60,34 +52,4 @@ public class NdefUtil { return new NdefRecord(NdefRecord.TNF_WELL_KNOWN, NdefRecord.RTD_URI, EMPTY, payload); } - - public static Iterable getTextFields(NdefMessage message) { - return Iterables.filter(getObjects(message), TextRecord.class); - } - - public static Iterable getUris(NdefMessage message) { - return Iterables.filter(getObjects(message), UriRecord.class); - } - - /** - * Parse the provided {@code NdefMessage}, extracting all known - * objects from the message. Typically this list will consist of - * {@link String}s corresponding to NDEF text records, or {@link Uri}s - * corresponding to NDEF URI records. - *

- * TODO: Is this API too generic? Should we keep it? - */ - public static Iterable getObjects(NdefMessage message) { - List retval = new ArrayList(); - for (NdefRecord record : message.getRecords()) { - if (UriRecord.isUri(record)) { - retval.add(UriRecord.parse(record)); - } else if (TextRecord.isText(record)) { - retval.add(TextRecord.parse(record)); - } else if (SmartPoster.isPoster(record)) { - retval.add(SmartPoster.parse(record)); - } - } - return retval; - } } diff --git a/apps/Tag/src/com/android/apps/tag/TagAdapter.java b/apps/Tag/src/com/android/apps/tag/TagAdapter.java index 04bc46aa4..44757c455 100644 --- a/apps/Tag/src/com/android/apps/tag/TagAdapter.java +++ b/apps/Tag/src/com/android/apps/tag/TagAdapter.java @@ -16,14 +16,10 @@ package com.android.apps.tag; -import com.android.apps.tag.TagDBHelper.NdefMessagesTable; - import android.content.Context; import android.database.Cursor; -import android.net.Uri; import android.nfc.FormatException; import android.nfc.NdefMessage; -import android.nfc.NdefRecord; import android.text.format.DateUtils; import android.util.Log; import android.view.LayoutInflater; @@ -32,9 +28,12 @@ import android.view.ViewGroup; import android.widget.Adapter; import android.widget.CursorAdapter; import android.widget.TextView; -import com.android.apps.tag.record.SmartPoster; -import com.android.apps.tag.record.TextRecord; -import com.android.apps.tag.record.UriRecord; + +import com.android.apps.tag.TagDBHelper.NdefMessagesTable; +import com.android.apps.tag.message.NdefMessageParser; +import com.android.apps.tag.message.ParsedNdefMessage; + +import java.util.Locale; /** * A custom {@link Adapter} that renders tag entries for a list. @@ -63,23 +62,8 @@ public class TagAdapter extends CursorAdapter { if (msg == null) { mainLine.setText("Invalid tag"); } else { - try { - SmartPoster poster = SmartPoster.parse(msg.getRecords()[0]); - TextRecord title = poster.getTitle(); - if (title != null) { - mainLine.setText(title.getText()); - } - } catch (IllegalArgumentException e) { - // Not a smart poster - NdefRecord record = msg.getRecords()[0]; - Uri uri = null; - try { - uri = UriRecord.parse(record).getUri(); - mainLine.setText(uri.toString()); - } catch (IllegalArgumentException e2) { - mainLine.setText("Not a smart poster or URL"); - } - } + ParsedNdefMessage parsedMsg = NdefMessageParser.parse(msg); + mainLine.setText(parsedMsg.getSnippet(Locale.getDefault())); } dateLine.setText(DateUtils.getRelativeTimeSpanString( context, cursor.getLong(cursor.getColumnIndex(NdefMessagesTable.DATE)))); diff --git a/apps/Tag/src/com/android/apps/tag/TagDBHelper.java b/apps/Tag/src/com/android/apps/tag/TagDBHelper.java index 3cb7844c1..dd11d9431 100644 --- a/apps/Tag/src/com/android/apps/tag/TagDBHelper.java +++ b/apps/Tag/src/com/android/apps/tag/TagDBHelper.java @@ -16,8 +16,6 @@ package com.android.apps.tag; -import com.google.common.annotations.VisibleForTesting; - import android.content.Context; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; @@ -27,6 +25,8 @@ import android.nfc.FormatException; import android.nfc.NdefMessage; import android.nfc.NdefRecord; +import com.google.common.annotations.VisibleForTesting; + /** * Database utilities for the saved tags. */ diff --git a/apps/Tag/src/com/android/apps/tag/TagList.java b/apps/Tag/src/com/android/apps/tag/TagList.java index 45f6f6577..7d09baed1 100644 --- a/apps/Tag/src/com/android/apps/tag/TagList.java +++ b/apps/Tag/src/com/android/apps/tag/TagList.java @@ -16,8 +16,6 @@ package com.android.apps.tag; -import com.android.apps.tag.TagDBHelper.NdefMessagesTable; - import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; @@ -35,6 +33,8 @@ import android.view.Menu; import android.view.View; import android.widget.ListView; +import com.android.apps.tag.TagDBHelper.NdefMessagesTable; + /** * An {@link Activity} that displays a flat list of tags that can be "opened". */ diff --git a/apps/Tag/src/com/android/apps/tag/TagViewer.java b/apps/Tag/src/com/android/apps/tag/TagViewer.java index aac93c6d1..a1d890020 100644 --- a/apps/Tag/src/com/android/apps/tag/TagViewer.java +++ b/apps/Tag/src/com/android/apps/tag/TagViewer.java @@ -30,10 +30,11 @@ import android.view.LayoutInflater; import android.view.WindowManager; import android.widget.LinearLayout; import android.widget.TextView; -import com.android.apps.tag.record.ParsedNdefRecord; -import com.android.apps.tag.record.SmartPoster; -import com.android.apps.tag.record.TextRecord; -import com.android.apps.tag.record.UriRecord; + +import com.android.apps.tag.message.NdefMessageParser; +import com.android.apps.tag.message.ParsedNdefMessage; + +import java.util.Locale; /** * An {@link Activity} which handles a broadcast of a new tag that the device just discovered. @@ -93,35 +94,11 @@ public class TagViewer extends Activity { // The body of the dialog should use the light theme // Build the views from the logical records in the messages - boolean first = true; for (NdefMessage msg : msgs) { - Iterable objects = NdefUtil.getObjects(msg); - for (ParsedNdefRecord object : objects) { - if (!first) { - list.addView(inflater.inflate(R.layout.tag_divider, list, false)); - first = false; - } - - if (object instanceof TextRecord) { - TextRecord textRecord = (TextRecord) object; - TextView text = (TextView) inflater.inflate(R.layout.tag_text, list, false); - text.setText(textRecord.getText()); - list.addView(text); - } else if (object instanceof UriRecord) { - UriRecord uriRecord = (UriRecord) object; - TextView text = (TextView) inflater.inflate(R.layout.tag_text, list, false); - text.setText(uriRecord.getUri().toString()); - list.addView(text); - } else if (object instanceof SmartPoster) { - TextView text = (TextView) inflater.inflate(R.layout.tag_text, list, false); - SmartPoster poster = (SmartPoster) object; - TextRecord title = poster.getTitle(); - if (title != null) { - text.setText(title.getText()); - } - list.addView(text); - } - } + ParsedNdefMessage parsedMsg = NdefMessageParser.parse(msg); + TextView text = (TextView) inflater.inflate(R.layout.tag_text, list, false); + text.setText(parsedMsg.getSnippet(Locale.getDefault())); + list.addView(text); } } diff --git a/apps/Tag/src/com/android/apps/tag/message/EmptyMessage.java b/apps/Tag/src/com/android/apps/tag/message/EmptyMessage.java new file mode 100644 index 000000000..48f9e9f85 --- /dev/null +++ b/apps/Tag/src/com/android/apps/tag/message/EmptyMessage.java @@ -0,0 +1,37 @@ +/* + * 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 com.android.apps.tag.message; + +import java.util.Locale; + +/** + * A parsed message containing no elements. + */ +class EmptyMessage implements ParsedNdefMessage { + + /* package private */ EmptyMessage() { } + + @Override + public String getSnippet(Locale locale) { + return "Empty Tag"; // TODO: localize + } + + @Override + public boolean isStarred() { + return false; + } +} diff --git a/apps/Tag/src/com/android/apps/tag/message/NdefMessageParser.java b/apps/Tag/src/com/android/apps/tag/message/NdefMessageParser.java new file mode 100644 index 000000000..1823f9847 --- /dev/null +++ b/apps/Tag/src/com/android/apps/tag/message/NdefMessageParser.java @@ -0,0 +1,76 @@ +/* + * 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 com.android.apps.tag.message; + +import android.nfc.NdefMessage; +import android.nfc.NdefRecord; + +import com.android.apps.tag.record.ParsedNdefRecord; +import com.android.apps.tag.record.SmartPoster; +import com.android.apps.tag.record.TextRecord; +import com.android.apps.tag.record.UriRecord; + +import java.util.ArrayList; +import java.util.List; + +/** + * Utility class for creating {@link ParsedNdefMessage}s. + */ +public class NdefMessageParser { + + // Utility class + private NdefMessageParser() { } + + /** Parse an NdefMessage */ + public static ParsedNdefMessage parse(NdefMessage message) { + List elements = getRecords(message); + + if (elements.isEmpty()) { + return new EmptyMessage(); + } + + ParsedNdefRecord first = elements.get(0); + + if (elements.size() == 1) { + if (first instanceof SmartPoster) { + return new SmartPosterMessage((SmartPoster) first); + } + if (first instanceof TextRecord) { + return new TextMessage((TextRecord) first); + } + if (first instanceof UriRecord) { + return new UriMessage((UriRecord) first); + } + } + + return new UnknownMessage(elements); + } + + public static List getRecords(NdefMessage message) { + List elements = new ArrayList(); + for (NdefRecord record : message.getRecords()) { + 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)); + } + } + return elements; + } +} diff --git a/apps/Tag/src/com/android/apps/tag/message/ParsedNdefMessage.java b/apps/Tag/src/com/android/apps/tag/message/ParsedNdefMessage.java new file mode 100644 index 000000000..427aae4c9 --- /dev/null +++ b/apps/Tag/src/com/android/apps/tag/message/ParsedNdefMessage.java @@ -0,0 +1,35 @@ +/* + * 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 com.android.apps.tag.message; + +import java.util.Locale; + +/** + * A parsed version of an {@link android.nfc.NdefMessage} + */ +public interface ParsedNdefMessage { + + /** + * Returns the snippet information associated with the NdefMessage + * most appropriate for the given {@code locale}. + */ + public String getSnippet(Locale locale); + + // TODO: Determine if this is the best place for holding whether + // the user has starred this parsed message. + public boolean isStarred(); +} diff --git a/apps/Tag/src/com/android/apps/tag/message/SmartPosterMessage.java b/apps/Tag/src/com/android/apps/tag/message/SmartPosterMessage.java new file mode 100644 index 000000000..28cd7b3c1 --- /dev/null +++ b/apps/Tag/src/com/android/apps/tag/message/SmartPosterMessage.java @@ -0,0 +1,48 @@ +/* + * 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 com.android.apps.tag.message; + +import com.android.apps.tag.record.SmartPoster; +import com.android.apps.tag.record.TextRecord; +import com.google.common.base.Preconditions; + +import java.util.Locale; + +/** + * A message consisting of one {@link SmartPoster} object. + */ +class SmartPosterMessage implements ParsedNdefMessage { + private final SmartPoster mPoster; + + SmartPosterMessage(SmartPoster poster) { + mPoster = Preconditions.checkNotNull(poster); + } + + @Override + public String getSnippet(Locale locale) { + TextRecord title = mPoster.getTitle(); + if (title == null) { + return mPoster.getUriRecord().getUri().toString(); + } + return title.getText(); + } + + @Override + public boolean isStarred() { + return false; + } +} diff --git a/apps/Tag/src/com/android/apps/tag/message/TextMessage.java b/apps/Tag/src/com/android/apps/tag/message/TextMessage.java new file mode 100644 index 000000000..3494331cf --- /dev/null +++ b/apps/Tag/src/com/android/apps/tag/message/TextMessage.java @@ -0,0 +1,43 @@ +/* + * 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 com.android.apps.tag.message; + +import com.android.apps.tag.record.TextRecord; +import com.google.common.base.Preconditions; + +import java.util.Locale; + +/** + * A message containing one text element + */ +class TextMessage implements ParsedNdefMessage { + private final TextRecord mRecord; + + TextMessage(TextRecord record) { + mRecord = Preconditions.checkNotNull(record); + } + + @Override + public String getSnippet(Locale locale) { + return mRecord.getText(); + } + + @Override + public boolean isStarred() { + return false; + } +} diff --git a/apps/Tag/src/com/android/apps/tag/message/UnknownMessage.java b/apps/Tag/src/com/android/apps/tag/message/UnknownMessage.java new file mode 100644 index 000000000..a30445fc3 --- /dev/null +++ b/apps/Tag/src/com/android/apps/tag/message/UnknownMessage.java @@ -0,0 +1,45 @@ +/* + * 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 com.android.apps.tag.message; + +import com.android.apps.tag.record.ParsedNdefRecord; +import com.google.common.collect.ImmutableList; + +import java.util.Locale; + +/** + * The catchall parsed message format for when nothing else better applies. + */ +class UnknownMessage implements ParsedNdefMessage { + + private final ImmutableList mRecords; + + UnknownMessage(Iterable records) { + mRecords = ImmutableList.copyOf(records); + } + + @Override + public String getSnippet(Locale locale) { + // TODO: localize + return "Unknown record type with " + mRecords.size() + " elements."; + } + + @Override + public boolean isStarred() { + return false; + } +} diff --git a/apps/Tag/src/com/android/apps/tag/message/UriMessage.java b/apps/Tag/src/com/android/apps/tag/message/UriMessage.java new file mode 100644 index 000000000..85bfa41f1 --- /dev/null +++ b/apps/Tag/src/com/android/apps/tag/message/UriMessage.java @@ -0,0 +1,45 @@ +/* + * 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 com.android.apps.tag.message; + +import com.android.apps.tag.record.UriRecord; +import com.google.common.base.Preconditions; + +import java.util.Locale; + +/** + * A {@link ParsedNdefMessage} consisting of one {@link UriRecord}. + */ +class UriMessage implements ParsedNdefMessage { + + private final UriRecord mRecord; + + UriMessage(UriRecord record) { + mRecord = Preconditions.checkNotNull(record); + } + + @Override + public String getSnippet(Locale locale) { + // URIs cannot be localized + return mRecord.getUri().toString(); + } + + @Override + public boolean isStarred() { + return false; + } +} diff --git a/apps/Tag/src/com/android/apps/tag/record/SmartPoster.java b/apps/Tag/src/com/android/apps/tag/record/SmartPoster.java index 54ac42405..935b23498 100644 --- a/apps/Tag/src/com/android/apps/tag/record/SmartPoster.java +++ b/apps/Tag/src/com/android/apps/tag/record/SmartPoster.java @@ -16,16 +16,16 @@ package com.android.apps.tag.record; -import com.android.apps.tag.NdefUtil; -import com.google.common.base.Preconditions; -import com.google.common.collect.Iterables; - import android.nfc.FormatException; import android.nfc.NdefMessage; import android.nfc.NdefRecord; -import java.util.Arrays; +import com.android.apps.tag.message.NdefMessageParser; +import com.google.common.base.Preconditions; +import com.google.common.collect.Iterables; +import java.util.Arrays; +import java.util.NoSuchElementException; import javax.annotation.Nullable; /** @@ -73,8 +73,12 @@ public class SmartPoster implements ParsedNdefRecord { Preconditions.checkArgument(Arrays.equals(record.getType(), NdefRecord.RTD_SMART_POSTER)); try { NdefMessage subRecords = new NdefMessage(record.getPayload()); - UriRecord uri = Iterables.getOnlyElement(NdefUtil.getUris(subRecords)); - Iterable textFields = NdefUtil.getTextFields(subRecords); + + Iterable records = NdefMessageParser.getRecords(subRecords); + + UriRecord uri = Iterables.getOnlyElement(Iterables.filter(records, UriRecord.class)); + Iterable textFields = Iterables.filter(records, TextRecord.class); + TextRecord title = null; if (!Iterables.isEmpty(textFields)) { title = Iterables.get(textFields, 0); @@ -83,6 +87,8 @@ public class SmartPoster implements ParsedNdefRecord { return new SmartPoster(uri, title); } catch (FormatException e) { throw new IllegalArgumentException(e); + } catch (NoSuchElementException e) { + throw new IllegalArgumentException(e); } } diff --git a/apps/Tag/src/com/android/apps/tag/record/TextRecord.java b/apps/Tag/src/com/android/apps/tag/record/TextRecord.java index 29d380d85..716e5afb7 100644 --- a/apps/Tag/src/com/android/apps/tag/record/TextRecord.java +++ b/apps/Tag/src/com/android/apps/tag/record/TextRecord.java @@ -17,6 +17,7 @@ package com.android.apps.tag.record; import android.nfc.NdefRecord; + import com.google.common.base.Preconditions; import java.io.UnsupportedEncodingException; @@ -27,6 +28,7 @@ import java.util.Arrays; */ public class TextRecord implements ParsedNdefRecord { + /** ISO/IANA language code */ private final String mLanguageCode; private final String mText; @@ -44,6 +46,11 @@ public class TextRecord implements ParsedNdefRecord { return mText; } + /** + * Returns the ISO/IANA language code associated with this text element. + * + * TODO: this should return a {@link java.util.Locale} + */ public String getLanguageCode() { return mLanguageCode; } diff --git a/apps/Tag/src/com/android/apps/tag/record/UriRecord.java b/apps/Tag/src/com/android/apps/tag/record/UriRecord.java index eeba30bd8..7d5e9bc6f 100644 --- a/apps/Tag/src/com/android/apps/tag/record/UriRecord.java +++ b/apps/Tag/src/com/android/apps/tag/record/UriRecord.java @@ -18,6 +18,7 @@ package com.android.apps.tag.record; import android.net.Uri; import android.nfc.NdefRecord; + import com.google.common.base.Preconditions; import com.google.common.collect.BiMap; import com.google.common.collect.ImmutableBiMap; diff --git a/apps/Tag/tests/src/com/android/apps/tag/NdefUtilTest.java b/apps/Tag/tests/src/com/android/apps/tag/NdefUtilTest.java index 24070ae12..297e754fc 100644 --- a/apps/Tag/tests/src/com/android/apps/tag/NdefUtilTest.java +++ b/apps/Tag/tests/src/com/android/apps/tag/NdefUtilTest.java @@ -16,10 +16,11 @@ package com.android.apps.tag; +import android.nfc.NdefRecord; import android.test.AndroidTestCase; + import com.android.apps.tag.record.TextRecord; import com.google.common.primitives.Bytes; -import android.nfc.NdefRecord; import java.io.UnsupportedEncodingException; diff --git a/apps/Tag/tests/src/com/android/apps/tag/SmartPosterTest.java b/apps/Tag/tests/src/com/android/apps/tag/SmartPosterTest.java index 8225197ce..9a5e644a8 100644 --- a/apps/Tag/tests/src/com/android/apps/tag/SmartPosterTest.java +++ b/apps/Tag/tests/src/com/android/apps/tag/SmartPosterTest.java @@ -16,8 +16,9 @@ package com.android.apps.tag; -import android.test.AndroidTestCase; import android.nfc.NdefMessage; +import android.test.AndroidTestCase; + import com.android.apps.tag.record.SmartPoster; /**