Add namespace handling in attribute values

Previously, you could only reference namespace prefixes in attribute names:

<View xmlns:appcompat="http://schemas.android.com/apk/res/android.support.v7.appcompat"
      appcompat:name="hey"
      ...

Now you can also reference them in resource names within an attribute value:

      ...
      android:text="@appcompat:string/confirm"
      ...

Which will be treated as "@android.support.v7.appcompat:string/confirm".

Change-Id: Ib076e867a990c80cf877a704eb77cd1ef0b23b52
diff --git a/tools/aapt2/ResourceTable.cpp b/tools/aapt2/ResourceTable.cpp
index 02be651..7f55395 100644
--- a/tools/aapt2/ResourceTable.cpp
+++ b/tools/aapt2/ResourceTable.cpp
@@ -318,12 +318,16 @@
 
     for (auto& otherType : other) {
         std::unique_ptr<ResourceTableType>& type = findOrCreateType(otherType->type);
-        if (type->publicStatus.isPublic && otherType->publicStatus.isPublic &&
-                type->typeId != otherType->typeId) {
-            Logger::error() << "can not merge type '" << type->type << "': conflicting public IDs "
-                            << "(" << type->typeId << " vs " << otherType->typeId << ")."
-                            << std::endl;
-            return false;
+        if (otherType->publicStatus.isPublic) {
+            if (type->publicStatus.isPublic && type->typeId != otherType->typeId) {
+                Logger::error() << "can not merge type '" << type->type
+                                << "': conflicting public IDs "
+                                << "(" << type->typeId << " vs " << otherType->typeId << ")."
+                                << std::endl;
+                return false;
+            }
+            type->publicStatus = std::move(otherType->publicStatus);
+            type->typeId = otherType->typeId;
         }
 
         for (auto& otherEntry : otherType->entries) {
@@ -335,13 +339,16 @@
             }
 
             std::unique_ptr<ResourceEntry>& entry = findOrCreateEntry(type, *nameToAdd);
-            if (entry->publicStatus.isPublic && otherEntry->publicStatus.isPublic &&
-                    entry->entryId != otherEntry->entryId) {
-                Logger::error() << "can not merge entry '" << type->type << "/" << entry->name
-                                << "': conflicting public IDs "
-                                << "(" << entry->entryId << " vs " << entry->entryId << ")."
-                                << std::endl;
-                return false;
+            if (otherEntry->publicStatus.isPublic) {
+                if (entry->publicStatus.isPublic && entry->entryId != otherEntry->entryId) {
+                    Logger::error() << "can not merge entry '" << type->type << "/" << entry->name
+                                    << "': conflicting public IDs "
+                                    << "(" << entry->entryId << " vs " << entry->entryId << ")."
+                                    << std::endl;
+                    return false;
+                }
+                entry->publicStatus = std::move(otherEntry->publicStatus);
+                entry->entryId = otherEntry->entryId;
             }
 
             for (ResourceConfigValue& otherValue : otherEntry->values) {