aboutsummaryrefslogtreecommitdiffstats
path: root/ide_common/src/com/android/ide/common
Commit message (Collapse)AuthorAgeFilesLines
* Rename ide_common to sdk_commonSiva Velusamy2012-09-1848-9666/+0
| | | | Change-Id: I1b39ee439a532f3f6758be35b569948e2e906665
* Constants refactoring.Tor Norbye2012-09-134-29/+17
| | | | | | | | | | | | | | | | 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
* Add Translation dialogTor Norbye2012-08-302-29/+56
| | | | | | | | | | This CL adds a dialog to the locale menu in the configuration chooser which makes it easy to add a new language into the set of languages used by the project. Also add some null annotations. Change-Id: I70ea2f623e6c56684e7b2a51b391f472bf31529b
* Unify all loggers in the sdk tools.Xavier Ducrohet2012-08-173-68/+2
| | | | | | | | | | Removed ILogger from ide_common Removed ISdkLog (and implementations) from sdklib Moved all existing code to com.android.utils.ILogger which is located in common. Change-Id: Icd674d4b8d10f6ae8b60a83acb43cc53c7a52137
* More refactoring.Xavier Ducrohet2012-08-132-0/+1418
| | | | | | | Move stuff out of sdklib into common and ide_common. Remove androidprefs and move the one class into common. Change-Id: I71d126a13cf2ba413692e29616f4968a37d7b33a
* Fix handling of @id/ resourcesTor Norbye2012-07-254-2/+21
| | | | | | | | | | | | | | | | | | | If you create a relative layout where one of the widgets create a new id such as @+id/button1, and then a later widget references this widget in a layout constraint using @id instead of @+id, such as layout_below="@id/button1", then it's possible for the resource repository to not update itself properly, and a subsequent layout editor render will generate error messages (can't find @id/button1). The problem is that the id parser was only looking up the resource repository for the @id reference, it was not also looking up the current resource file, to see if an @id reference is valid. This made it erroneously mark an error, and therefore return false from the parse method. This then had the cascaded effect of not updating the repository information from the parse, so the newly added id didn't get added to the maps. Change-Id: Iae3d215897525582579faf1c8ba64260215fec9d
* Added GLE support for devicesMichael Wright2012-06-251-0/+11
| | | | Change-Id: I4e82e93563529540d31af8809aba79f40610fa2e
* Added FolderConfig creation and config loading for DevicesMichael Wright2012-06-181-0/+101
| | | | Change-Id: Iae7b32df991df946bba22aba5ab9b32ed2c094ea
* Rename template file from _ prefixTor Norbye2012-06-181-1/+1
| | | | | | | | | | One of the template files ended up not getting packaged, probably because it started with a "_". Also, add @Override to some methods overriding a superclass method (onCreate(Bundle)) and fix an NPE. Change-Id: Ic2f15d968cca156704146bdc4ec501d1359a7620
* Set default sizes for framework resource maps to avoid resizingTor Norbye2012-06-111-4/+41
| | | | Change-Id: I09b9538032dfff71f5e3b09d5271ebb286ed36c7
* Merge "Populate ResourceFolder contents on demand"Tor Norbye2012-06-111-35/+126
|\
| * Populate ResourceFolder contents on demandTor Norbye2012-06-101-35/+126
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are scenarios where clients call getFile(String name) on a ResourceFolder before the ResourceFolder is updated after a file change. For example, creating a new layout file can result in this scenario, which causes a number of "Current file is not a match for the given config." error messages in the layout editor. This changeset fixes this such that if an existing file is not found for a given name, it also checks the file system to see if the file really exists, and if so, it processes it and adds it to the list. It also makes some performance improvements. First, the code which processes a resource folder would check each added file to see if already existed in the list of resource files. This resource file list was just stored as a list, so when adding files from a large folder (such as the framework drawable-mdpi folder which has 1,200 files, each successive added file would be compared against the previous n-1 files, O(n^2).) This changeset now stores a separate name map such that it can quickly determine whether a file is already known. Second, since some of the folders in the framework are large (and their sizes are roughly known up front), it creates the data structures with larger up front sizes (depending on the folder type) to avoid expensive rehashing and array copying. Change-Id: Ieaab955d7f165e790e8a8dccebf4d0878fde6fce
* | Merge "Performance improvement"Xavier Ducrohet2012-06-112-85/+51
|\ \ | |/ |/|
| * Performance improvementMichal Sova2012-05-172-85/+51
| | | | | | | | | | | | List changed to map Change-Id: I8145a2e177937cbeb1f6b06b2e313faf8e3a1176
* | Improve search of items into style for legacy layoutlibs.Xavier Ducrohet2012-05-161-9/+7
|/ | | | | | | | | | | | | Legacy versions uses the old API that doesn't specify the namespace of the attribute being queried. The implementation used the namespace of the style as the namespace of the attribute but this make little sense. At better implementation searches in the project's namespace and, if the attribute is not found, then searches in the framework namespace. Change-Id: Ief43ecd45f108162de2b1512027d4eedf2c132db
* Work around initialization bugsTor Norbye2012-04-191-1/+11
| | | | | | | | | | | | | | | | This bug fixes some bugs related to resource initialization. Note that these are probably not fixing the root cause, but they are making the symptoms less severe. I happened to run into a scenario where I triggered the problem (the editor came up blank, see issue http://code.google.com/p/android/issues/detail?id=21935 for example), and I verified that reopening the editor after these fixes worked. How the resource repository came to be empty to begin with is not clear. In addition to issue 21935 this workaround may also help with issue http://code.google.com/p/android/issues/detail?id=17522 Change-Id: I0166e8c58c790888d53c46ca03348a0d8edc75b0
* Speed up loadPublicResources()Tor Norbye2012-03-221-34/+110
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The FrameworkResources method which loads in the public resources takes about ~500ms of the target loading time. This changeset optimizes this down to < 50ms using the following three optimizations: 1) Precompute a map from names to ResourceItems before processing the public names. Before this, it would search sequentially through the name list, which when done n times meant O(n^2); we can construct the map in O(n) and then perform n lookups in O(1) => O(n). Also, be smart about which maps we precompute names for: the ResourceType.PUBLIC and ResourceType.DECLARE_STYLEABLE types have about 2,000 items, none of which are public, so skip precomputing maps for these two. (However, keep the linear search around such that if any are exported in the future the code will work correctly. Similarly, we know "roughly" the size of the final public maps, so initialize them in the right size range such that they don't have to do any internal resize+copy operations as we insert into them. 2) In android-15 there are 1500 new <java-symbol> elements in the public xml file, which were being processed, doubling the number of exported symbols. Limit the processing to only the <public> tags. 3) Switch from DOM parsing to pull parsing. This helps since more than half the file consists of <java-symbol> elements, and we can ignore whitespace and id attributes etc, so there is much less object creation involved. Change-Id: I4761e1182b9bc0c50fe94aea7dcd9690754c7908
* Properly support attr ns when used in styles.Xavier Ducrohet2012-03-162-11/+46
| | | | | | | | | | | | | Previously we just stripped the namespace prefix when reading attribute names in styles and declare-styleables. This was bad if one created a declare-styleable mixing platform and app attributes that were named the same. This change is Eclipse side only and prevents ADT crashed (due to stack overflows) but the rendering won't be correct. An updated version of layoutlib using API 8 is necessary. Change-Id: I3029f3e06cdd96cd46af511bb029bc5274b935ad
* Add info about when qualifiers were added to the platform.Xavier Ducrohet2012-03-1621-0/+117
| | | | | | | | 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
* Make sure to remove obsolete id from the res repo after a delete.Xavier Ducrohet2012-02-221-2/+2
| | | | Change-Id: I5a42a436dd9d21a632af175a860a85aa1d3b5a1d
* Fix locale handling of uppercase/lowercaseTor Norbye2012-01-062-2/+5
| | | | | | | | | | | | | | | | | This changeset fixes issue 23747: i and İ character problem in turkish operating Systems... and probably many other bugs in the Turkish locale. Basically, we had a lot of String.toLowerCase() and String.toUpperCase() calls. This performs locale sensitive conversions, which in many cases is NOT what we want; for "machine readable" conversions we should be using Locale.US which performs no special cases. For more, see http://developer.android.com/reference/java/util/Locale.html#default_locale Change-Id: I996b0e70fb377e8dae484c5811deb8bc9afb684c
* Update SDK codebase to JDK 6Tor Norbye2011-12-219-3/+17
| | | | | | | | | | | | | | | | | | | | | This changeset makes the SDK codebase compile with source=1.6 (which means it also requires JDK 6). This means that methods implementing an interface requires @Override's. It also means we can start using APIs like the ArrayDeque class and methods like String#isEmpty(). This changeset looks big but the change is trivial: it's basically adding @Override in all the places that need it, along with some other automatic Eclipse cleanup in certain files (such as reordering imports where they were incorrectly ordered (because older versions of Eclipse didn't always handle inner classes right)), as well as cleaning up trailing whitespace and removing some $NON-NLS-1$ markers on lines where there aren't any string literals anymore. This changeset also sets the source and target JDK level to 6 in the Eclipse compiler .settings file, and synchronizes this file to all the other Eclipse SDK projects. Change-Id: I6a9585aa44c3dee9a5c00739ab22fbdbcb9f8275
* Lint Architecture Changes: Configurations, Categories, etc.Tor Norbye2011-11-071-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changeset makes various architectural changes to lint: (1) Add configurations, which are basically user preferences for lint in a given project, such as providing a custom severity for an issue, or disabling a specific warning in a specific file. In Eclipse, there is a project configuration (stored in lint.xml in each project), as well as a global configuration (stored using Eclipse preference data). Project configurations inherit from the global configuration. The options dialog now shows up both as a project property page (showing the issue state for the project configuration), as well as a normal preference page (showing the global or "fallback" configuraiton). I also changed the Options UI for issues from a Table to a TreeViewer to add in category nodes, and changed the checkbox UI to have a custom severity toggle instead. The lint quickfixes also now have 3 suppression options: * Ignore in this file * Ignore in this project * Disable check (2) Change detectors to be registered by class and instantiated for each lint run rather than having a fixed list of detectors get reused over and over. Turns out that since some detectors store state, this prevented lints from running concurrently since the two runs could stomp each other's state. To do this effectively I've also switched from a DetectorRegistry to an IssueRegistry, which contains the global list of available issues and each issue can point to the class detecting the issue (and these are created on the fly based on parameters like scope.) (3) Explicit Categories. Categories used to just be a string property on issues; now it's an explicit class with both a name and an explanation, with parents to allow nesting (such that for example the Usability category has an Icons sub category), and finally the category class provides sorting. Categories also show up in the HTML Report now as separate sections. (4) Other API changes: * I changed the package containing APIs for lint clients to an explicit "client" package * Moved the LintConstants class up from lint-checks to lint-api and added a LintUtils class which contains many generic methods that were spread around in specific detectors. * The detectors are now talking to a wrapper client rather than directly to lint clients, such that the wrapper client can filter out results on disabled checks etc, which means that tools can assume they always get correct reports and don't have to worry about improperly written detectors. * I renamed ToolContext to LintClient. * I got rid of the "isEnabled" state, which was a bit redundant with the severity since severity has a Severity.IGNORE value. * I added a LintListener interface, which notifies about progress (and the CLI tool will print "."'s for each processed file unless suppressed with -q). * A new dispose method on the parser interface to for example allow IDEs to lock/unlock read models on underlying data. (5) I added a toolbar action for running Lint on the currently selected project. I also added an --xml export option intended for use with CI plugins. Change-Id: Icadd9b2d14d075234d97b31398806111af747b7b
* Clean up layout and menu file scanning codeTor Norbye2011-09-028-103/+330
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changeset fixes some issues around the new lazy scanning of layout and menu files. First, it partly fixes "19657: AAPT errors aren't shown when adding an error to a valid XML file". With the new optimization of not running aapt on layout files where no ids have changed, we would no longer pick up changes where an invalid or nonexistent resource is added. We now perform some basic validation of resources as well as XML parsing errors. Second, it fixes a bug in the id before and after comparison used to determine if aapt needs to run: The code would call map.keySet() before and after the ids were added, but this resolved to the same keyset so the equals comparison was always true regardless of the content. Third, it fixes an infinite loop issue with library projects, and avoids doing unnecessary classpath modifications when there are no changed projects. Finally, it changes the "needsId" flag. The state of whether aapt needs to be run was stored per repository, and there is a bug where it does not get cleared properly which can yield a compilation loop. This changeset introduces a new "ScanningContext" object which is passed down to the various resource file updater methods. This context object now holds the needsId state object (which is renamed to "needsFullAapt"), and it is also the object where errors can be registered. Change-Id: I5632612c2d93e2f10f0803e9223921adb67602be
* Fix NPE in ResourceFolder when deleting foldersTor Norbye2011-09-011-4/+6
| | | | | | | | | | | | This CL fixes an NPE I was hitting when deleting resource folders in an Android project - looks like the children list is populated lazily and dispose does not account for this java.lang.NullPointerException at ResourceFolder.dispose(ResourceFolder.java:131) at ResourceRepository.removeFolder(ResourceRepository.java:146) Change-Id: I96974c68b4ef13e6e348efd6269270d4525322ab
* Precompilation only executes AAPT when necessaryJosiah Gaskin2011-08-184-10/+94
| | | | | | | | | | | | | | | | | | | This change adds resource tracking to the ResourceManager. Each ResourceRepository now has new methods: void markForIdRefresh() to set the repository as "dirty" boolean needsIdRefresh() to check whether the repository is dirty void setIdsRefreshed() to set the repository as "clean" During the precompilation step, the PreCompiler will query the ResourceManager to see if any of the repositories included in the build are marked as dirty. AAPT will only be run if one or more dirty repositories are found. Repositories are marked as clean when R.java is regenerated and IDs are set in ProjectResources. Change-Id: I575ab819702508eacd247b282c3de8979f2f0ab9
* Fix NPETor Norbye2011-08-041-3/+5
| | | | Change-Id: I044342e5aa6b3aaa87efdcc79bbcb3db93190252
* ADT Resource Repo stores IDs and Called OnceJosiah Gaskin2011-08-013-1/+276
| | | | | | | | | | | | | | | | | | 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
* merge from tools_r12The Android Open-Source Project2011-06-281-2/+4
|\ | | | | | | Change-Id: I83911d9ee56e5d44045a5ecbd28647a551f8ea79
| * Guard against a possible NPE when the rendering fails.Xavier Ducrohet2011-06-281-2/+4
| | | | | | | | Change-Id: I8b0a0c65f2b0d7b7faf10224ac2945081605c5c4
| * Merge df07f53c from master to r12. do not merge.Xavier Ducrohet2011-06-141-1/+3
| | | | | | | | | | | | | | | | Fix parsing of the styleable enum/flag attribute values. Better handling for hexa value > 0x7FFFFFFF Change-Id: I1cbbed8f9d3ce9f1b7396e2d34c7bd33dc18e70f
| * Merge 9d342967 from master to r12. do not merge.Xavier Ducrohet2011-06-143-9/+28
| | | | | | | | | | | | Fix broken equals() in new qualifiers. Change-Id: Id083d11a2941d120ca6fd9438a5a12ed7502ab92
* | Fix value parser to handle attr values not in declare-styleable.Xavier Ducrohet2011-06-243-43/+68
| | | | | | | | | | | | | | Also change the layoutlib sample code to properly get the list of framework attr flag/enum values. Change-Id: Ie0bf126a0fab574d94d0f86b7b2f8581cf4eaae3
* | Sample code to use the layout rendering library.Xavier Ducrohet2011-06-231-0/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is very basic sample code showing how to render a layout. This explains how to load the resources, create Folderconfig, ResourceResolver, and how to call the LayoutLibrary to do an actual render. There are some big limitations: - can't render custom views because there's nothing compiling them and generating the compiled R.class file. - not all features of ADT are present because there are things that don't make sense outside of an editor (render in context, expand empty layouts, etc...) Change-Id: I0c8676ebfbff27f0e9412bb4b13193ce64082372
* | Merge "Fix parsing of the styleable enum/flag attribute values."Xavier Ducrohet2011-06-141-1/+3
|\ \
| * | Fix parsing of the styleable enum/flag attribute values.Xavier Ducrohet2011-06-141-1/+3
| |/ | | | | | | | | | | Better handling for hexa value > 0x7FFFFFFF Change-Id: If0c2ed23847a720431bceee95f8b264ceb967e3e
* | Fix broken equals() in new qualifiers.Xavier Ducrohet2011-06-143-9/+28
|/ | | | Change-Id: Ide197a390c3d9de8d4e30a8f99f0a32a6ad2191d
* Revert ScreenLayoutSize to ScreenSize.Xavier Ducrohet2011-06-092-14/+14
| | | | | | | | | | | | 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-095-62/+62
| | | | Change-Id: I9c5ea5183e115582e0b805ca3ec75aad70e4a65c
* Add support for the new width/height resource qualifiers.Xavier Ducrohet2011-06-095-20/+641
| | | | | | Also add Television to the dock mode (which is really UI Mode). Change-Id: I97e3fbea1806a32d8267d8e462211add2b122ed0
* Add proper styleable support.Xavier Ducrohet2011-06-072-24/+55
| | | | Change-Id: I2dc79e71521f93d798fd4a9b33aa59979bef379d
* Improve error message when ADT is older than layoutlib.Xavier Ducrohet2011-06-031-2/+3
| | | | Change-Id: I1d52201c58f9fb92a87fd42585b653bf37730032
* Detect and add special warning for wrong themesTor Norbye2011-05-231-5/+14
| | | | | | | | | | | | | | | | | | | If you open a layout designed for a particular theme in another theme, you can get many confusing error messages. Instead of "attribute missing" it may tell you that it failed to convert a resource to a color or drawable, and so on. To help guide users to the root problem (wrong theme chosen) this changeset detects the scenario where theme attributes can't be resolved, and when these are found the top of the error log will start with a bold message stating that theme resources were not found and to check whether the correct theme is chosen. To do this, the resource resolver emits a new sub-type of the resource missing tag into the error log, which is used in the IDE to prefix the errors with the special error message. Change-Id: Ic29c9af37da4b5cc2c9fb1ca5670c8b8f79bf852
* Fix issue with resource repository when using librariesXavier Ducrohet2011-05-201-1/+2
| | | | Change-Id: I1a3e5ba9ac6e930d4be2daedff9691862f975408
* Add method to LayoutLibrary to query layoutlib api level and rev.Xavier Ducrohet2011-05-191-0/+27
| | | | Change-Id: Ib70e560e7d0be88305383aac18726858d91990ae
* Add baseline/margins to ViewInfo.Xavier Ducrohet2011-05-161-25/+160
| | | | | | | Also make it so that older layoutlib that are using API5 return the value through reflection (done in LayoutLibrary.) Change-Id: I3a32666e525f0f1d37a13e670d1d1c659b8e2027
* Add getViewBaseline to the LayoutLibrary class.Xavier Ducrohet2011-04-181-0/+17
| | | | Change-Id: I29caadc8cb31c4a3aab0863a4fec16534b9bc900
* Move getViewParent/Index from RenderSession to Bridge.Xavier Ducrohet2011-04-061-1/+35
| | | | | | Also update the IProjectCallback to handle expandableListView. Change-Id: I36ca8733182bbd9d169fee3e709ebc532fef7b1e
* Pick layout themes from manifest registrations and target SDKTor Norbye2011-04-041-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Extract Style RefactoringTor Norbye2011-03-311-1/+1
| | | | | | | | | | | | | | | Adds a new refactoring, "Extract Style", which will show the user the attributes for the current selected elements (or if invoked from an editor context, the attributes overlapping the current caret or editor selection). The user can select which attributes to extract, and these are then added as a new style in the styles.xml file in the project (which is created if necessary). The user can optionally replace the attributes that were extracted, and the user can also optionally set the style attribute on the elements to the new style. (Both are on by default.) This is integrated with the refactoring quick assistant as well. Change-Id: I0504e86a824b00730482607150a879ff28233618