AAPT2: Fix small issue with detecting translatable resources

Change-Id: Idd21b5de4d20be06c6f8c8eb5a22ccd68afc4927
diff --git a/tools/aapt2/ResourceParser.cpp b/tools/aapt2/ResourceParser.cpp
index 2d6c0c2..39a4116 100644
--- a/tools/aapt2/ResourceParser.cpp
+++ b/tools/aapt2/ResourceParser.cpp
@@ -446,11 +446,11 @@
         }
     }
 
-    bool untranslateable = false;
-    if (Maybe<StringPiece16> untranslateableAttr = findAttribute(parser, u"untranslateable")) {
-        if (!ResourceUtils::tryParseBool(untranslateableAttr.value(), &untranslateable)) {
+    bool translateable = mOptions.translatable;
+    if (Maybe<StringPiece16> translateableAttr = findAttribute(parser, u"translatable")) {
+        if (!ResourceUtils::tryParseBool(translateableAttr.value(), &translateable)) {
             mDiag->error(DiagMessage(source)
-                         << "invalid value for 'untranslateable'. Must be a boolean");
+                         << "invalid value for 'translatable'. Must be a boolean");
             return false;
         }
     }
@@ -461,10 +461,10 @@
         return false;
     }
 
-    if (formatted || untranslateable) {
+    if (formatted && translateable) {
         if (String* stringValue = valueCast<String>(outResource->value.get())) {
             if (!util::verifyJavaStringFormat(*stringValue->value)) {
-                mDiag->error(DiagMessage(mSource.withLine(parser->getLineNumber()))
+                mDiag->error(DiagMessage(source)
                              << "multiple substitutions specified in non-positional format; "
                                 "did you mean to add the formatted=\"false\" attribute?");
                 return false;
@@ -973,6 +973,9 @@
     const Source source = mSource.withLine(parser->getLineNumber());
     std::unique_ptr<Styleable> styleable = util::make_unique<Styleable>();
 
+    // Declare-styleable is always public, because it technically only exists in R.java.
+    outResource->symbolState = SymbolState::kPublic;
+
     std::u16string comment;
     bool error = false;
     const size_t depth = parser->getDepth();