diff options
author | Adam Lesinski <adamlesinski@google.com> | 2015-12-17 13:03:11 -0800 |
---|---|---|
committer | Adam Lesinski <adamlesinski@google.com> | 2016-01-06 12:05:41 -0800 |
commit | 393b5f0d6130d3848dd82075986a5cf40c09ce44 (patch) | |
tree | 5643311ac74ad383b2efa37fee2f3d21878cf6d8 /tools/aapt2/ResourceValues.h | |
parent | 24b8ff0faf7c59323d0171cdd825ca09e712aa1e (diff) |
AAPT2: Port AAPT pseudolocalization to AAPT2
Pseudolocalization happens at the compile phase. Pseudolocalized
values are weak, such that manually specified values will take precedence.
Change-Id: I5e064ce0d270c9f4f9022f75aecedab9d45bc980
Diffstat (limited to 'tools/aapt2/ResourceValues.h')
-rw-r--r-- | tools/aapt2/ResourceValues.h | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/tools/aapt2/ResourceValues.h b/tools/aapt2/ResourceValues.h index a03828206c91..8e317dbcd1b1 100644 --- a/tools/aapt2/ResourceValues.h +++ b/tools/aapt2/ResourceValues.h @@ -43,9 +43,15 @@ struct Value { /** * Whether this value is weak and can be overridden without - * warning or error. Default for base class is false. + * warning or error. Default is false. */ - virtual bool isWeak() const; + bool isWeak() const { + return mWeak; + } + + void setWeak(bool val) { + mWeak = val; + } /** * Returns the source where this value was defined. @@ -95,6 +101,7 @@ struct Value { protected: Source mSource; std::u16string mComment; + bool mWeak = false; }; /** @@ -159,7 +166,7 @@ struct Reference : public BaseItem<Reference> { * An ID resource. Has no real value, just a place holder. */ struct Id : public BaseItem<Id> { - bool isWeak() const override; + Id() { mWeak = true; } bool flatten(android::Res_value* out) const override; Id* clone(StringPool* newPool) const override; void print(std::ostream* out) const override; @@ -185,9 +192,17 @@ struct String : public BaseItem<String> { String(const StringPool::Ref& ref); + // Whether the string is marked as translateable. This does not persist when flattened. + // It is only used during compilation phase. + void setTranslateable(bool val); + bool isTranslateable() const; + bool flatten(android::Res_value* outValue) const override; String* clone(StringPool* newPool) const override; void print(std::ostream* out) const override; + +private: + bool mTranslateable; }; struct StyledString : public BaseItem<StyledString> { @@ -195,9 +210,17 @@ struct StyledString : public BaseItem<StyledString> { StyledString(const StringPool::StyleRef& ref); + // Whether the string is marked as translateable. This does not persist when flattened. + // It is only used during compilation phase. + void setTranslateable(bool val); + bool isTranslateable() const; + bool flatten(android::Res_value* outValue) const override; StyledString* clone(StringPool* newPool) const override; void print(std::ostream* out) const override; + +private: + bool mTranslateable; }; struct FileReference : public BaseItem<FileReference> { @@ -232,7 +255,6 @@ struct Attribute : public BaseValue<Attribute> { uint32_t value; }; - bool weak; uint32_t typeMask; int32_t minInt; int32_t maxInt; @@ -240,7 +262,6 @@ struct Attribute : public BaseValue<Attribute> { Attribute(bool w, uint32_t t = 0u); - bool isWeak() const override; Attribute* clone(StringPool* newPool) const override; void printMask(std::ostream* out) const; void print(std::ostream* out) const override; |