aboutsummaryrefslogtreecommitdiffstats
path: root/common/src/com/android
Commit message (Collapse)AuthorAgeFilesLines
* Merge "Add allowBackup lint security check"Tor Norbye2012-09-211-0/+1
|\
| * Add allowBackup lint security checkTor Norbye2012-09-211-0/+1
| | | | | | | | Change-Id: I3b79bef6981d880fe6a545429754e03bd384645c
* | Merge "Move some utility functions from AdtUtils to common"Siva Velusamy2012-09-211-0/+136
|\ \
| * | Move some utility functions from AdtUtils to commonSiva Velusamy2012-09-201-0/+136
| |/ | | | | | | Change-Id: Ia6f5c55e07c7f60712472c8e850b7c4595c46671
* | Merge "Validate user edits in XML files"Tor Norbye2012-09-201-0/+3
|\ \
| * | Validate user edits in XML filesTor Norbye2012-09-201-0/+3
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Around ADT 15 or so we introduced a bunch of optimizations to run AAPT much less frequently, since with large projects it can take a long time, and end up blocking the UI if you try to save twice. Unfortunately, one side effect of this change is that if you edit only the *value* of an attribute, we will not re-run aapt, which means that if you set the value to a bogus value, you will get no error message until the next time AAPT runs (usually when you try to run). This changeset fixes this. We already have the attribute metadata which aapt uses, so now, when an XML file is changed and saved, we process it with an XML pull parser, and validate all the Android namespace attributes. If any are found to not be correct, then we request a full AAPT process, which will then display errors as appropriate. Change-Id: I374c19648e29c27c6d82616b3ee602cb2343cd3a
* | 37497: Templates should escape string literals in resource filesTor Norbye2012-09-181-0/+21
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | If the user enters an activity title like "Android's Tools" in the new template wizard, an invalid strings.xml file is generated, since the apostrophe is not properly escaped. To fix this, there's a new string conversion method in the template engine, "escapeXmlString", which will perform all the necessary conversions. It also adds two other XML escaping functions: one to escape text to be suitable for XML attribute values, and one to be suitable for XML text values. Finally, when verifying this, I discovered that if I inserted ampersands in the MasterDetail template, I ended up with errors in various places there a filename was derived from the input string. To help make this work better, there's also a new "extractLetters" method which pulls all the characters out of a string (effectively stripping whitespace and punctuation). In addition to the above 4 new string conversion methods, the templates have been updated to use them, and the template format documentation updated. Change-Id: I4d4e854ab78d63bc86b8eb0fb9d92246534615e7
* Improvements to stacktrace handler for constructorsTor Norbye2012-09-181-0/+1
| | | | | | | | | | | | | | | | | This changeset improves the SourceRevealer for certain types of stacktraces: (1) Constructors. If your class initializes fields using code, these are logically grouped into the constructor, but the linenumbers do not fit the constructor source range. Before this CL, this would cause the revealer to show the constructor method rather than the field initialization line. (2) Class initializers. If you clicked on a class initializer method, the IDE would throw an NPE. There's now some special handling to deal with these. Change-Id: Ibb3b7dcf13a69018f75fd12648d1f6b5c45625cc
* Add labelFor lint checkTor Norbye2012-09-171-0/+3
| | | | Change-Id: If2b905197d5d81c6f98315a0d48ff37091e8282b
* Support separate layout editors for a single layout resourceTor Norbye2012-09-171-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changeset changes the "reuse" behavior of the layout editor to no longer reuse the same layout editor when you are switching between alternate layout files for the same layout resource, such as layout/foo.xml and layout-land/foo.xml. This lets you more quickly switch back and forth and inspect differences between the layouts, etc. There is also an option in the Android > Editors panel to turn on single editor sharing again. The biggest part of the changeset, by far, is a cleanup of the ConfigurationComposite class and associated code. This was necessary not just to support the above feature (where we need to "back out" UI changes when you've made a configuration edit which results in a different file getting opened), but it's also an important preparation for multi configuration editing, where we need to be able to switch configuration settings in and out of a single configuration editor, etc. The configuration data itself is now in a separate Configuration class; the UI is in ConfigurationChooser, and the configuration matching code is in ConfigurationMatcher. There's also a new Locale class to track language/region pairs instead of using 2-element ResourceQualifier arrays. The various menu listeners are also in separate UI classes now. While there are new classes, most of the configuration matching algorithm is unchanged, just moved to a new class and the UI syncing and configuration data lookup replaced. Bitmasks are used to handle configuration changes, such that updating multiple related attributes (e.g. a rendering target change also causes a theme change if say Holo isn't available) can now be processed just once with a single change call. (Various other cleanup too.) Change-Id: I04ac969f46824321be3db0c487ef077c03cc6012
* Constants refactoring.Tor Norbye2012-09-133-218/+754
| | | | | | | | | | | | | | | | This changeset moves most constants into the SdkConstants class, and gets rid of AndroidConstants and LintConstants. It also migrates all non-ADT specific constants from AdtConstants into SdkConstants. It furthermore moves various other constants (such as those in XmlUtils and ValuesDescriptors) into the constants class. It also fixes the modifier order to be the canonical modifier order (JLS 8.x). Finally, it removes redundancy and combines various constant aliases such that we don't have both NAME_ATTR and ATTR_NAME pointing to "name", etc. Change-Id: Ifd1755016f62ce2dd80e5c76130d6de4b0e32161
* NPW Sample Wizard: list extras with a "sample" directory.Raphael Moll2012-09-111-0/+9
| | | | | | | | Some extras have just a single "sample" directory instead of having a samples/<sample_name> directory. Support this and list them as valid samples. Change-Id: I25bc59db0b9853d98385cca98f70bf261558fd8b
* Fix nullability annotationsTor Norbye2012-08-212-4/+6
| | | | | | | | | | | Eclipse 3.8/4.2 requires that any method which overrides another method with a @NonNull parameter (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=381443). This changeset adds @NonNull on various overriding methods in newly added code such that Eclispe 4.2 doesn't show errors. Change-Id: Ice4a4b4dc31ba68c4e0911bb37c15da090076a0d
* Merge "Create new logging class in the common library."Xavier Ducrohet2012-08-154-1/+309
|\
| * Create new logging class in the common library.Xavier Ducrohet2012-08-154-1/+309
| | | | | | | | | | | | | | | | | | The goal is to later migrate all existing code to this new logger and get rid of all our duplicates. Also did a misc fix in AndroidLocation. Change-Id: Ia33a782b57c91b4e3d5fd2c0660e040be11b9cbb
* | Add Ant support for UI automation test.Xavier Ducrohet2012-08-151-2/+2
|/ | | | | | | Also fix a bug in a custom ant task where minSdkVersion and targetApi were swapped. Change-Id: Id9bac802377a04270e76def42eaf6a8fb4b3f874
* More refactoring.Xavier Ducrohet2012-08-134-0/+1096
| | | | | | | Move stuff out of sdklib into common and ide_common. Remove androidprefs and move the one class into common. Change-Id: I71d126a13cf2ba413692e29616f4968a37d7b33a
* Refactor common.jarXavier Ducrohet2012-08-0718-1584/+3
| | | | | | | | | | | | | | | Move resources and com.android.util.Pair into layoutlib_api where they belong since layoutlib depends on them and we need to control the API. Made a copy of Pair to stay in common.jar but moved it to com.android.utils.Pair (the one in com.android.util.Pair is marked as deprecated to prevent usage where applicable). Also moved XmlUtil and PositionXmlParser to com.android.utils to match Pair. Change-Id: I21d7057d3f2ce604f86a3bb1fa3c130948c93b89
* Tweaks to the lint CLI offsetsTor Norbye2012-07-231-1/+2
| | | | Change-Id: I20592372d41235b36227a0d36014d77c23c7fc58
* Add XXHigh density (added in JB)Xavier Ducrohet2012-07-101-0/+1
| | | | Change-Id: I09f308a3187d93abfda23c63ed72ba906b65ebc9
* Add typo detectorTor Norbye2012-06-221-14/+58
| | | | | | | | | | | This changeset adds a new typo detector. There are also some lint infrastructure fixes to better handle positions within text nodes, and to allow Eclipse lint quickfixes to supply multiple fixes for a single issue (such as multiple misspelling alternative replacements.) Change-Id: Ie26f0bafc571e02ae09ff27a7f4b221fe0c2ea5b
* Fix nullness annotationsTor Norbye2012-05-304-4/+4
| | | | | | | | | | | | | | | | | | | Eclipse 4.2 includes analysis support for @Nullable and @NonNull annotations. However, it requires these annotations to be *repeated* on every single method implementing or overriding a superclass or interface method (!). This changeset basically applies the quickfixes to inline these annotations. It also changes the retention of our nullness annotations from source to class, since without this Eclipse believes that a @NonNull annotation downstream is a redefinition of a @Nullable annotation. Finally, the null analysis revealed a dozen or so places where the nullness annotation was either wrong, or some null checking on parameters or return values needed to be done. Change-Id: I43b4e56e2d025a8a4c92a8873f55c13cdbc4c1cb
* Move XML code to the common libraryTor Norbye2012-05-201-0/+253
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The ManifestMerger library needs to look up the prefix to use for the Android namespace, and the Document.lookupPrefix method is not implemented by the Eclipse DOM implementation (which throws an exception). However, we have an implementation of this in the ADT plugin. This changeset creates a new XmlUtils class in the common/ library (which is accessible by both ADT and the manifest merger, and the anttasks where the manifest merger is used), and moves the namespace prefix lookup code in there. It also moves the XML escape methods into that class. It also adds a new method to the ManifestMerger for merging directly from documents (rather than files), and makes sure that all the merging code goes via the prefix utility method rather than calling the document.lookupPrefix method. Finally, it moves the various string constants associated with XML namespaces into the single XmlUtils class, since these were spread across several different classes before (and many of them are needed in the XmlUtils class). The vast majority of the diffs in this changeset are related to simple import statement changes to reflect the new locations of these constants. Change-Id: Ib8f3d0e5c89e47e61ea509a23925af7b6580abee
* Ensure that exception during build put a marker on something.Xavier Ducrohet2012-03-272-5/+27
| | | | | | | | Failure to read the manifest (sometimes due to out of sync resources) could fail to put a marker on the file or project, making the build fail with no feedback. Change-Id: Ib75e0b72e202e14de556ba30f23a6879e3dfc2c8
* Add info about when qualifiers were added to the platform.Xavier Ducrohet2012-03-161-7/+13
| | | | | | | | This is a first step where we setup the info. Next step is to actually use the info when calling ResourceRepository.getConfiguredResources Change-Id: I03c20ad0ec7a53ec8219316cc4af7a59155ef34a
* Add support for suppressing lint via XML attributesTor Norbye2012-02-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | This changeset adds support for suppressing in XML files: (1) Lint will ignore errors found in attributes and elements if the element (or any surrounding parent elements) specifies a tools:ignore="id-list" attribute where the id-list matches the id of the reported issue (or "all"). The "tools" prefix can be any prefix bound to the namespace "http://schemas.android.com/tools" (2) There's a new quickfix shown for XML lint warnings which offers to add a lint suppress attribute for a given lint warning (setting the id to the id of the warning, and adding the tools namespace binding if necessary). (3) The XML formatter now handles namespaces a bit better: after the preferred attributes (id, name, style, layout params, etc) have been handled, attributes are sorted by namespace prefix before they are sorted by local name -- which effectively will sort any new tools:ignore attributes to the end. Change-Id: Id7474cde5665d9bd29bdd4e0d0cc89ed4d422aea
* Fix lint column offset handling, and add columns to API checkTor Norbye2012-01-301-5/+4
| | | | | | | | | | | | | | | | | | | | The Lint API specifies that columns should be 0-based (like line numbers), but in a number of places this was not the case; it was 1-based instead (both in the detector code and in the output code, which is why things looked okay). This changeset cleans this up such that the columns are properly 0-based (and adds unit tests for it). The Location API has a mechanism to search in the source code for tokens, which is useful for bytecode detectors where we only have line numbers. This changeset adds tokens to the API detectors such that it identifies the corresponding method, class or field reference in the source, not just the corresponding line. It also improves the pattern search to also look backwards a few lines, since some bytecode references appear a few lines later than the source code reference (at the nearest executable code; this is the case for parameter local variables for example). Change-Id: I3adac20d5f0075e0a919be15dfb68658d5b7bb11
* Fix a few misc Lint issuesTor Norbye2012-01-261-51/+61
| | | | | | | | | | | | | | | | | | | | First, stop reporting Java-related parser errors as lint errors. Lombok fails to parse a few files (see http://code.google.com/p/projectlombok/issues/detail?id=311) and even when it fails, the error messages aren't useful (see http://code.google.com/p/projectlombok/issues/detail?id=313). Second, the XML parser could throw an exception in some circumstances, because it passes invalid column numbers at the end of the file. This CL guards against that (and against any other potential errors by wrapping all exceptions during parsing as a SAXEception). Finally, fix the positions reported in text nodes for the ExtraText check such that it points to the line containing the extra text, not the beginning of the text node (which is frequently the previous line). Change-Id: I9630ea49d30d8afdc8bd9cf2c87ca0a0306b8ec5
* Tweak encoding sniffer to look for \r to avoid looking at whole docTor Norbye2012-01-061-1/+1
| | | | Change-Id: I189118b8612661e3c9aef4aaca0feeb7ac522f5b
* Merge "Extract positional XML parser into common and fix encoding issues"Tor Norbye2012-01-0614-0/+745
|\
| * Extract positional XML parser into common and fix encoding issuesTor Norbye2012-01-0514-0/+745
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The XML DOM parser used by the lint CLI driver (which tracks positions) is needed outside of lint, so pull it out of the lint/cli project, and refactor it such that it does not directly reference the lint Position APIs (but can utilize them when subclassed in lint). In addition, handle non-UTF-8 file encodings. XML files can be encoded in other character sets, and can specify this via the encoding attribute in the XML prologue. Until now, the CLI lint runner would just read the XML file contents in using the default encoding and parse this. Now there's a new utility method which takes a byte[] and infers the desired encoding and uses that to convert the byte[] into a string using the correct encoding. (We can't just pass an InputStream and let the SAX parser handle this on its own because the XML parser needs to access the character stream in order to assign correct node offsets.) This code now also handles the byte order mark more cleanly. There are some new unit tests too to check the new encoding, BOM and offset handling. Change-Id: Ib0badbbe72172e3408c6d5af2413be51280a7724
* | Fix a couple of incorrect license headersTor Norbye2012-01-054-10/+10
|/ | | | Change-Id: I42bfb03bace8a96ad0af75106facd2bbb7d54894
* Add @NonNull annotation and configure Eclipse settingsTor Norbye2011-12-223-4/+103
| | | | | | | | | | | | | | This changeset adds a new @NonNull annotation, to match our existing @Nullable annotation, and it adds configuration settings for Eclipse 3.8 / Eclipse 4.2 which configures the new null analysis there to use our own annotations. Note that the annotations only have source retention so there is no extra size or class-loading overhead. (To use findbugs you'll need to temporarily change retention to class-level.) In upcoming CL's I'll use these annotations to clarify the Lint API and other APIs. Change-Id: I99096d8b8a7e25ef002624d592da7700195a5872
* Rename default.prop/build.prop to project.prop/ant.propXavier Ducrohet2011-08-231-0/+5
| | | | | | | Opening projects in Eclipse will rename the file and "android update project" will do the same. Change-Id: I251881897c251eb07c9704eb9c2448cab47e5b83
* ADT Resource Repo stores IDs and Called OnceJosiah Gaskin2011-08-011-0/+2
| | | | | | | | | | | | | | | | | | This change makes ADT parse out @+id declarations from layout and menu files and store them in its ResourceRepository. This eliminates the need to merge in IDs from the generated R.java in order to have a complete repository of resources. In order to do this, a new type of ResourceFile is created: IdGeneratingResourceFile which is used for xml files in menu/ and layout/. Also includes an IdResourceParser which finds all the declared IDs in an XML. This change also includes a change to the ResourceMananger to process raw deltas that can be provided either from the PreCompilerBuilder or from the GlobalProjectManager. This is to avoid duplicate deltas being passed to ResourceManager when autobuilding. Change-Id: I1c705a5f5a01ce7daa3eb76f14bd6cb9e11b5248
* Revert ScreenLayoutSize to ScreenSize.Xavier Ducrohet2011-06-091-8/+8
| | | | | | | | | | | | I hadn't noticed that LayoutLib actually uses ScrenSize through the tools-common-prebuilt.jar, so this API is (somewhat*) frozen. * Somewhat because LayoutLib.jar actually only uses Density and ScreenSize but not the other enums (yet?) so the rename of DockMode is not a problem. Change-Id: Ida3360b0111abd96d2a27c16833b282706774fb6
* Renamed some resource enum/qualifiers to be more consistent with the platform.Xavier Ducrohet2011-06-092-20/+20
| | | | Change-Id: I9c5ea5183e115582e0b805ca3ec75aad70e4a65c
* Add support for the new width/height resource qualifiers.Xavier Ducrohet2011-06-091-1/+2
| | | | | | Also add Television to the dock mode (which is really UI Mode). Change-Id: I97e3fbea1806a32d8267d8e462211add2b122ed0
* Add support for the TV dpi.Xavier Ducrohet2011-06-031-0/+1
| | | | Change-Id: I97fedc69644d83801b50d7882bb759db7089d8f0
* Pick layout themes from manifest registrations and target SDKTor Norbye2011-04-042-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changeset changes the way the layout editor picks themes when a layout is opened. It used to just pick the first available theme in the theme chooser. Now it performs the following checks, in order: * Does this layout have a persisted theme setting from a previous run of the tool? If yes, use it. * Can the activity for this layout be determined? If so, look at the manifest registration for the corresponding activity, and if it specifies a theme, use it. * If not, does the manifest specify a default theme for the project? If so, use it. * If not, is the target SDK version (or the minimum SDK version, if the target is not specified) at least API level 11 or higher? If so, the default theme is "Theme.Holo" * If not, the default theme is "Theme". * If the file to be opened is included from some other layout, use the no-decorations versions of the default layouts, e.g. Theme.NoTitleBar or Theme.Holo.NoActionBar. * At the end of this resolution, the computed theme is stored as the persisted theme setting for this layout, so the above algorithm will only be computed once. We might want to tweak this such that it distinguishes between a default computation of a theme and a manual user choice of a theme. * If the file is opened as "Show Included In" (e.g. rendered within an outer file) then the theme chosen is the one for the outer file. During startup, this information will be asked for each and every layout being reopened, so there is now a "ManifestInfo" class attached to the project which keeps manifest information around. It checks the timestamp of the AndroidManifest.xml file and refreshes its information lazily if necessary. All themes mentioned in the manifest are listed in a special section at the top of the theme chooser (below the entry for the default computed described above). The code to look up the associated Activity of a layout is using a simple heuristic: it looks for usages of the corresponding R.layout field, and prefers references from methods called onCreate or in classes whose superclass name ends with Activity. I tried a different approach where I searched for usages of Activity.setContentView(int) but this failed to identify a number of cases where the activity was doing some simple logic and didn't pass the layout id directly as a parameter in setContentView, so I went back to the basic approach. Change-Id: Ibd3c0f089fefe38e6e6c607d65524990699c86d3
* Move FolderTypeRelationship to common.jarXavier Ducrohet2011-02-251-0/+164
| | | | Change-Id: I3a151d2fadd1c1e34177cb729fe5545fa754849a
* Move ResourceFolderType into common.Xavier Ducrohet2011-02-243-2/+130
| | | | | | | Moved some constants from sdklib (which is not a dependency of common but instead depends on common) into common. Change-Id: I6fdfbad4e77813a9f2a2ca9ea0d740692d8bce5b
* Move the sdk io classes to common.jarXavier Ducrohet2011-02-246-0/+504
| | | | Change-Id: I59a7b770071707ed058aa104bab8a16aa8950d56
* Add MipMap to the resource type list.Xavier Ducrohet2011-01-281-0/+1
| | | | Change-Id: I1f56ab470874e39dad8659d15a3699b83f1ac658
* Move Pair and annoatations into resources.jar now renamed as common.jarXavier Ducrohet2011-01-2816-0/+1464
Move all the resource query methods that returned an array of 2 Strings to return a pair of ResourceType and String. Change-Id: I6b8447aa27005de786e2defef81ad88a72363523