Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 17 | syntax = "proto3"; |
| 18 | |
Adam Lesinski | b58c3ef | 2017-09-12 17:39:52 -0700 | [diff] [blame] | 19 | import "frameworks/base/tools/aapt2/Configuration.proto"; |
| 20 | |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 21 | package aapt.pb; |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 22 | |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 23 | option java_package = "com.android.aapt"; |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 24 | option optimize_for = LITE_RUNTIME; |
| 25 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 26 | // A string pool that wraps the binary form of the C++ class android::ResStringPool. |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 27 | message StringPool { |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 28 | bytes data = 1; |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 29 | } |
| 30 | |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 31 | // The position of a declared entity within a file. |
| 32 | message SourcePosition { |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 33 | uint32 line_number = 1; |
| 34 | uint32 column_number = 2; |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 35 | } |
| 36 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 37 | // Developer friendly source file information for an entity in the resource table. |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 38 | message Source { |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 39 | // The index of the string path within the source string pool of a ResourceTable. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 40 | uint32 path_idx = 1; |
| 41 | SourcePosition position = 2; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | // Top level message representing a resource table. |
| 45 | message ResourceTable { |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 46 | // The string pool containing source paths referenced throughout the resource table. This does |
| 47 | // not end up in the final binary ARSC file. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 48 | StringPool source_pool = 1; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 49 | |
| 50 | // Resource definitions corresponding to an Android package. |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 51 | repeated Package package = 2; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 52 | } |
| 53 | |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 54 | // A package ID in the range [0x00, 0xff]. |
| 55 | message PackageId { |
| 56 | uint32 id = 1; |
| 57 | } |
| 58 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 59 | // Defines resources for an Android package. |
| 60 | message Package { |
| 61 | // The package ID of this package, in the range [0x00, 0xff]. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 62 | // - ID 0x00 is reserved for shared libraries, or when the ID is assigned at run-time. |
| 63 | // - ID 0x01 is reserved for the 'android' package (framework). |
| 64 | // - ID range [0x02, 0x7f) is reserved for auto-assignment to shared libraries at run-time. |
| 65 | // - ID 0x7f is reserved for the application package. |
| 66 | // - IDs > 0x7f are reserved for the application as well and are treated as feature splits. |
| 67 | // This may not be set if no ID was assigned. |
| 68 | PackageId package_id = 1; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 69 | |
| 70 | // The Java compatible Android package name of the app. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 71 | string package_name = 2; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 72 | |
| 73 | // The series of types defined by the package. |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 74 | repeated Type type = 3; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 75 | } |
| 76 | |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 77 | // A type ID in the range [0x01, 0xff]. |
| 78 | message TypeId { |
| 79 | uint32 id = 1; |
| 80 | } |
| 81 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 82 | // A set of resources grouped under a common type. Such types include string, layout, xml, dimen, |
| 83 | // attr, etc. This maps to the second part of a resource identifier in Java (R.type.entry). |
| 84 | message Type { |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 85 | // The ID of the type. This may not be set if no ID was assigned. |
| 86 | TypeId type_id = 1; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 87 | |
| 88 | // The name of the type. This corresponds to the 'type' part of a full resource name of the form |
| 89 | // package:type/entry. The set of legal type names is listed in Resource.cpp. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 90 | string name = 2; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 91 | |
| 92 | // The entries defined for this type. |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 93 | repeated Entry entry = 3; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 94 | } |
| 95 | |
| 96 | // The status of a symbol/entry. This contains information like visibility (public/private), |
| 97 | // comments, and whether the entry can be overridden. |
| 98 | message SymbolStatus { |
| 99 | // The visibility of the resource outside of its package. |
| 100 | enum Visibility { |
| 101 | // No visibility was explicitly specified. This is typically treated as private. |
| 102 | // The distinction is important when two separate R.java files are generated: a public and |
| 103 | // private one. An unknown visibility, in this case, would cause the resource to be omitted |
| 104 | // from either R.java. |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 105 | UNKNOWN = 0; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 106 | |
| 107 | // A resource was explicitly marked as private. This means the resource can not be accessed |
| 108 | // outside of its package unless the @*package:type/entry notation is used (the asterisk being |
| 109 | // the private accessor). If two R.java files are generated (private + public), the resource |
| 110 | // will only be emitted to the private R.java file. |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 111 | PRIVATE = 1; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 112 | |
| 113 | // A resource was explicitly marked as public. This means the resource can be accessed |
| 114 | // from any package, and is emitted into all R.java files, public and private. |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 115 | PUBLIC = 2; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 116 | } |
| 117 | |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 118 | Visibility visibility = 1; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 119 | |
| 120 | // The path at which this entry's visibility was defined (eg. public.xml). |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 121 | Source source = 2; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 122 | |
| 123 | // The comment associated with the <public> tag. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 124 | string comment = 3; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 125 | |
| 126 | // Whether the symbol can be merged into another resource table without there being an existing |
| 127 | // definition to override. Used for overlays and set to true when <add-resource> is specified. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 128 | bool allow_new = 4; |
| 129 | } |
| 130 | |
| 131 | // An entry ID in the range [0x0000, 0xffff]. |
| 132 | message EntryId { |
| 133 | uint32 id = 1; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 134 | } |
| 135 | |
| 136 | // An entry declaration. An entry has a full resource ID that is the combination of package ID, |
| 137 | // type ID, and its own entry ID. An entry on its own has no value, but values are defined for |
| 138 | // various configurations/variants. |
| 139 | message Entry { |
| 140 | // The ID of this entry. Together with the package ID and type ID, this forms a full resource ID |
| 141 | // of the form 0xPPTTEEEE, where PP is the package ID, TT is the type ID, and EEEE is the entry |
| 142 | // ID. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 143 | // This may not be set if no ID was assigned. |
| 144 | EntryId entry_id = 1; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 145 | |
| 146 | // The name of this entry. This corresponds to the 'entry' part of a full resource name of the |
| 147 | // form package:type/entry. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 148 | string name = 2; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 149 | |
| 150 | // The symbol status of this entry, which includes visibility information. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 151 | SymbolStatus symbol_status = 3; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 152 | |
| 153 | // The set of values defined for this entry, each corresponding to a different |
| 154 | // configuration/variant. |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 155 | repeated ConfigValue config_value = 4; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | // A Configuration/Value pair. |
| 159 | message ConfigValue { |
Adam Lesinski | b58c3ef | 2017-09-12 17:39:52 -0700 | [diff] [blame] | 160 | Configuration config = 1; |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 161 | Value value = 2; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 162 | } |
| 163 | |
| 164 | // The generic meta-data for every value in a resource table. |
| 165 | message Value { |
| 166 | // Where the value was defined. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 167 | Source source = 1; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 168 | |
| 169 | // Any comment associated with the value. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 170 | string comment = 2; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 171 | |
| 172 | // Whether the value can be overridden. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 173 | bool weak = 3; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 174 | |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 175 | // The value is either an Item or a CompoundValue. |
| 176 | oneof value { |
| 177 | Item item = 4; |
| 178 | CompoundValue compound_value = 5; |
| 179 | } |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 180 | } |
| 181 | |
| 182 | // An Item is an abstract type. It represents a value that can appear inline in many places, such |
| 183 | // as XML attribute values or on the right hand side of style attribute definitions. The concrete |
| 184 | // type is one of the types below. Only one can be set. |
| 185 | message Item { |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 186 | oneof value { |
| 187 | Reference ref = 1; |
| 188 | String str = 2; |
| 189 | RawString raw_str = 3; |
| 190 | StyledString styled_str = 4; |
| 191 | FileReference file = 5; |
| 192 | Id id = 6; |
| 193 | Primitive prim = 7; |
| 194 | } |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | // A CompoundValue is an abstract type. It represents a value that is a made of other values. |
| 198 | // These can only usually appear as top-level resources. The concrete type is one of the types |
| 199 | // below. Only one can be set. |
| 200 | message CompoundValue { |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 201 | oneof value { |
| 202 | Attribute attr = 1; |
| 203 | Style style = 2; |
| 204 | Styleable styleable = 3; |
| 205 | Array array = 4; |
| 206 | Plural plural = 5; |
| 207 | } |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 208 | } |
| 209 | |
| 210 | // A value that is a reference to another resource. This reference can be by name or resource ID. |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 211 | message Reference { |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 212 | enum Type { |
| 213 | // A plain reference (@package:type/entry). |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 214 | REFERENCE = 0; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 215 | |
| 216 | // A reference to a theme attribute (?package:type/entry). |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 217 | ATTRIBUTE = 1; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 218 | } |
| 219 | |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 220 | Type type = 1; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 221 | |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 222 | // The resource ID (0xPPTTEEEE) of the resource being referred. This is optional. |
| 223 | uint32 id = 2; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 224 | |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 225 | // The name of the resource being referred. This is optional if the resource ID is set. |
| 226 | string name = 3; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 227 | |
| 228 | // Whether this reference is referencing a private resource (@*package:type/entry). |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 229 | bool private = 4; |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 230 | } |
| 231 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 232 | // A value that represents an ID. This is just a placeholder, as ID values are used to occupy a |
| 233 | // resource ID (0xPPTTEEEE) as a unique identifier. Their value is unimportant. |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 234 | message Id { |
| 235 | } |
| 236 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 237 | // A value that is a string. |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 238 | message String { |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 239 | string value = 1; |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 240 | } |
| 241 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 242 | // A value that is a raw string, which is unescaped/uninterpreted. This is typically used to |
| 243 | // represent the value of a style attribute before the attribute is compiled and the set of |
| 244 | // allowed values is known. |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 245 | message RawString { |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 246 | string value = 1; |
Adam Lesinski | 0853500 | 2017-08-04 16:15:17 -0700 | [diff] [blame] | 247 | } |
| 248 | |
| 249 | // A string with styling information, like html tags that specify boldness, italics, etc. |
| 250 | message StyledString { |
| 251 | // The raw text of the string. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 252 | string value = 1; |
Adam Lesinski | 0853500 | 2017-08-04 16:15:17 -0700 | [diff] [blame] | 253 | |
| 254 | // A Span marks a region of the string text that is styled. |
| 255 | message Span { |
| 256 | // The name of the tag, and its attributes, encoded as follows: |
| 257 | // tag_name;attr1=value1;attr2=value2;[...] |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 258 | string tag = 1; |
Adam Lesinski | 0853500 | 2017-08-04 16:15:17 -0700 | [diff] [blame] | 259 | |
| 260 | // The first character position this span applies to, in UTF-16 offset. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 261 | uint32 first_char = 2; |
Adam Lesinski | 0853500 | 2017-08-04 16:15:17 -0700 | [diff] [blame] | 262 | |
| 263 | // The last character position this span applies to, in UTF-16 offset. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 264 | uint32 last_char = 3; |
Adam Lesinski | 0853500 | 2017-08-04 16:15:17 -0700 | [diff] [blame] | 265 | } |
| 266 | |
| 267 | repeated Span span = 2; |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 268 | } |
| 269 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 270 | // A value that is a reference to an external entity, like an XML file or a PNG. |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 271 | message FileReference { |
Adam Lesinski | e59f0d8 | 2017-10-13 09:36:53 -0700 | [diff] [blame] | 272 | enum Type { |
| 273 | UNKNOWN = 0; |
| 274 | PNG = 1; |
| 275 | BINARY_XML = 2; |
| 276 | PROTO_XML = 3; |
| 277 | } |
| 278 | |
Adam Lesinski | 0853500 | 2017-08-04 16:15:17 -0700 | [diff] [blame] | 279 | // Path to a file within the APK (typically res/type-config/entry.ext). |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 280 | string path = 1; |
Adam Lesinski | e59f0d8 | 2017-10-13 09:36:53 -0700 | [diff] [blame] | 281 | |
| 282 | // The type of file this path points to. For UAM bundle, this cannot be |
| 283 | // BINARY_XML. |
| 284 | Type type = 2; |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 285 | } |
| 286 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 287 | // A value that represents a primitive data type (float, int, boolean, etc.). |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 288 | message Primitive { |
Michael Wachenschwanz | d06f1f3 | 2018-01-11 18:36:22 -0800 | [diff] [blame^] | 289 | message NullType { |
| 290 | } |
| 291 | message EmptyType { |
| 292 | } |
| 293 | oneof oneof_value { |
| 294 | NullType null_value = 1; |
| 295 | EmptyType empty_value = 2; |
| 296 | float float_value = 3; |
| 297 | float dimension_value = 4; |
| 298 | float fraction_value = 5; |
| 299 | int32 int_decimal_value = 6; |
| 300 | uint32 int_hexidecimal_value = 7; |
| 301 | bool boolean_value = 8; |
| 302 | uint32 color_argb8_value = 9; |
| 303 | uint32 color_rgb8_value = 10; |
| 304 | uint32 color_argb4_value = 11; |
| 305 | uint32 color_rgb4_value = 12; |
| 306 | } |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 307 | } |
| 308 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 309 | // A value that represents an XML attribute and what values it accepts. |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 310 | message Attribute { |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 311 | // A Symbol used to represent an enum or a flag. |
| 312 | message Symbol { |
| 313 | // Where the enum/flag item was defined. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 314 | Source source = 1; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 315 | |
| 316 | // Any comments associated with the enum or flag. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 317 | string comment = 2; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 318 | |
| 319 | // The name of the enum/flag as a reference. Enums/flag items are generated as ID resource |
| 320 | // values. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 321 | Reference name = 3; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 322 | |
| 323 | // The value of the enum/flag. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 324 | uint32 value = 4; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 325 | } |
| 326 | |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 327 | // Bitmask of formats allowed for an attribute. |
| 328 | enum FormatFlags { |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 329 | NONE = 0x0; // Proto3 requires a default of 0. |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 330 | ANY = 0x0000ffff; // Allows any type except ENUM and FLAGS. |
| 331 | REFERENCE = 0x01; // Allows Reference values. |
| 332 | STRING = 0x02; // Allows String/StyledString values. |
| 333 | INTEGER = 0x04; // Allows any integer BinaryPrimitive values. |
| 334 | BOOLEAN = 0x08; // Allows any boolean BinaryPrimitive values. |
| 335 | COLOR = 0x010; // Allows any color BinaryPrimitive values. |
| 336 | FLOAT = 0x020; // Allows any float BinaryPrimitive values. |
| 337 | DIMENSION = 0x040; // Allows any dimension BinaryPrimitive values. |
| 338 | FRACTION = 0x080; // Allows any fraction BinaryPrimitive values. |
| 339 | ENUM = 0x00010000; // Allows enums that are defined in the Attribute's symbols. |
| 340 | // ENUM and FLAGS cannot BOTH be set. |
| 341 | FLAGS = 0x00020000; // Allows flags that are defined in the Attribute's symbols. |
| 342 | // ENUM and FLAGS cannot BOTH be set. |
| 343 | } |
| 344 | |
| 345 | // A bitmask of types that this XML attribute accepts. Corresponds to the flags in the |
| 346 | // enum FormatFlags. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 347 | uint32 format_flags = 1; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 348 | |
| 349 | // The smallest integer allowed for this XML attribute. Only makes sense if the format includes |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 350 | // FormatFlags::INTEGER. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 351 | int32 min_int = 2; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 352 | |
| 353 | // The largest integer allowed for this XML attribute. Only makes sense if the format includes |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 354 | // FormatFlags::INTEGER. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 355 | int32 max_int = 3; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 356 | |
| 357 | // The set of enums/flags defined in this attribute. Only makes sense if the format includes |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 358 | // either FormatFlags::ENUM or FormatFlags::FLAGS. Having both is an error. |
| 359 | repeated Symbol symbol = 4; |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 360 | } |
| 361 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 362 | // A value that represents a style. |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 363 | message Style { |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 364 | // An XML attribute/value pair defined in the style. |
| 365 | message Entry { |
| 366 | // Where the entry was defined. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 367 | Source source = 1; |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 368 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 369 | // Any comments associated with the entry. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 370 | string comment = 2; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 371 | |
| 372 | // A reference to the XML attribute. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 373 | Reference key = 3; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 374 | |
| 375 | // The Item defined for this XML attribute. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 376 | Item item = 4; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 377 | } |
| 378 | |
| 379 | // The optinal style from which this style inherits attributes. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 380 | Reference parent = 1; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 381 | |
| 382 | // The source file information of the parent inheritance declaration. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 383 | Source parent_source = 2; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 384 | |
| 385 | // The set of XML attribute/value pairs for this style. |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 386 | repeated Entry entry = 3; |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 387 | } |
| 388 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 389 | // A value that represents a <declare-styleable> XML resource. These are not real resources and |
| 390 | // only end up as Java fields in the generated R.java. They do not end up in the binary ARSC file. |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 391 | message Styleable { |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 392 | // An attribute defined for this styleable. |
| 393 | message Entry { |
| 394 | // Where the attribute was defined within the <declare-styleable> block. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 395 | Source source = 1; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 396 | |
| 397 | // Any comments associated with the declaration. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 398 | string comment = 2; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 399 | |
| 400 | // The reference to the attribute. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 401 | Reference attr = 3; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 402 | } |
| 403 | |
| 404 | // The set of attribute declarations. |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 405 | repeated Entry entry = 1; |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 406 | } |
| 407 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 408 | // A value that represents an array of resource values. |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 409 | message Array { |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 410 | // A single element of the array. |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 411 | message Element { |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 412 | // Where the element was defined. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 413 | Source source = 1; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 414 | |
| 415 | // Any comments associated with the element. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 416 | string comment = 2; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 417 | |
| 418 | // The value assigned to this element. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 419 | Item item = 3; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 420 | } |
| 421 | |
| 422 | // The list of array elements. |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 423 | repeated Element element = 1; |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 424 | } |
| 425 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 426 | // A value that represents a string and its many variations based on plurality. |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 427 | message Plural { |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 428 | // The arity of the plural. |
| 429 | enum Arity { |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 430 | ZERO = 0; |
| 431 | ONE = 1; |
| 432 | TWO = 2; |
| 433 | FEW = 3; |
| 434 | MANY = 4; |
| 435 | OTHER = 5; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 436 | } |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 437 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 438 | // The plural value for a given arity. |
| 439 | message Entry { |
| 440 | // Where the plural was defined. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 441 | Source source = 1; |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 442 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 443 | // Any comments associated with the plural. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 444 | string comment = 2; |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 445 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 446 | // The arity of the plural. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 447 | Arity arity = 3; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 448 | |
| 449 | // The value assigned to this plural. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 450 | Item item = 4; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 451 | } |
| 452 | |
| 453 | // The set of arity/plural mappings. |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 454 | repeated Entry entry = 1; |
| 455 | } |
| 456 | |
| 457 | // Defines an abstract XmlNode that must be either an XmlElement, or |
| 458 | // a text node represented by a string. |
| 459 | message XmlNode { |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 460 | oneof node { |
| 461 | XmlElement element = 1; |
| 462 | string text = 2; |
| 463 | } |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 464 | |
| 465 | // Source line and column info. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 466 | SourcePosition source = 3; |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 467 | } |
| 468 | |
| 469 | // An <element> in an XML document. |
| 470 | message XmlElement { |
| 471 | // Namespaces defined on this element. |
| 472 | repeated XmlNamespace namespace_declaration = 1; |
| 473 | |
| 474 | // The namespace URI of this element. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 475 | string namespace_uri = 2; |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 476 | |
| 477 | // The name of this element. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 478 | string name = 3; |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 479 | |
| 480 | // The attributes of this element. |
| 481 | repeated XmlAttribute attribute = 4; |
| 482 | |
| 483 | // The children of this element. |
| 484 | repeated XmlNode child = 5; |
| 485 | } |
| 486 | |
| 487 | // A namespace declaration on an XmlElement (xmlns:android="http://..."). |
| 488 | message XmlNamespace { |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 489 | string prefix = 1; |
| 490 | string uri = 2; |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 491 | |
| 492 | // Source line and column info. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 493 | SourcePosition source = 3; |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 494 | } |
| 495 | |
| 496 | // An attribute defined on an XmlElement (android:text="..."). |
| 497 | message XmlAttribute { |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 498 | string namespace_uri = 1; |
| 499 | string name = 2; |
| 500 | string value = 3; |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 501 | |
| 502 | // Source line and column info. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 503 | SourcePosition source = 4; |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 504 | |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 505 | // The optional resource ID (0xPPTTEEEE) of the attribute. |
| 506 | uint32 resource_id = 5; |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 507 | |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 508 | // The optional interpreted/compiled version of the `value` string. |
| 509 | Item compiled_item = 6; |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 510 | } |