aboutsummaryrefslogtreecommitdiffstats
path: root/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common
Commit message (Collapse)AuthorAgeFilesLines
* Fix ADT grid layout editor support in KitKatTor Norbye2013-11-141-2/+10
| | | | Change-Id: Id6560a014a3cc41635d10d7ee3a1f386fa8f72ad
* Update GravityHelper to handle start|end gravititiesTor Norbye2013-04-111-12/+41
| | | | Change-Id: Id3628f87569cab8df14f885274137a332a074550
* Fix attribute validationTor Norbye2013-01-041-1/+15
| | | | | | | This is used when incrementally validating XML attributes when a file is saved in the IDE. Change-Id: I37d37ab8ac64aec72455c3bfbabc7bbd65595a94
* Merge "Grid Layout tweaks"Tor Norbye2012-12-055-33/+204
|\
| * Grid Layout tweaksTor Norbye2012-12-045-33/+204
| | | | | | | | | | | | | | | | | | | | | | This switches the grid layout rule editor over to the more traditional grid-oriented editing, and makes some tweaks to that handling (along with some bug fixes for namespace handling). This is a better editing experience than the richer but currently broken free form editing of GridLayouts. Change-Id: I4db2c604ddf34e37c6fe4dd2b8270d20c68dc12f
* | Code completion improvements for custom views and themesTor Norbye2012-12-043-2/+54
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changeset adds custom view completion to the content assist. Code completion for elements (e.g. from text context or inside a <) should now include custom views found in the project, and prefix typing should work as well. Similarly, code completing inside a <fragment> name attribute or a <view> class attribute should complete fragment and view classes. It will display javadocs for these classes, if available. It also hooks up class completion in manifest files, so completing <activity>, <application>, <receiver> etc android:name attributes should show matching classes corresponding to the tag being edited. The completion will also always complete theme references (?) even when there is no known metadata for the tag, such as for an arbitrary custom view. Also fix descriptor metadata such that <view> and <requestFocus> show up in code completion, works properly for layout editor palette drag (with a class selection popup) and with a suitable outline icon. Also tweak refactoring such that it handles both class= and android:name usage for <fragment> elements. Finally, for the LinearLayout automatically added inside new ScrollViews, set the vertical attribute since that's usually what you want. Change-Id: Ifc98c19607ddc4e69d7645f2720120ce72d0cd95
* Add resource renaming supportTor Norbye2012-11-261-24/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changeset adds support for renaming resources. There are several new hooks for initiating a resource rename: (1) You can use the same keybinding as in Java files from XML files to initiate refactoring; for example, place the caret somewhere in @+id/foo or @string/bar and hit the refactoring keybinding, and a rename resource refactoring dialog shows up. (2) Invoking Quick Assistant in an XML file (Ctrl/Cmd 1) will offer to rename the resource, if the caret is over a resource name. (3) Renaming an XML or bitmap resource file, such as res/drawable-hdpi/foo.png, will now initiate the same XML resource naming machinery as above to update all resource references, plus it will also update all the other versions of the same file (e.g. in res/drawable-mdpi, res/drawable-xhdpi, etc.). Assuming an R field exists (e.g. the project has been built), it will also optionally update all Java field references. (4) Invoking renaming in the layout editor (via the rename keybinding, or via the context menu, or via the property sheet's "..." button) will also initiate id resource refactoring. Editing the id directly in the inline editor for the id will pop up a dialog asking whether to update references as well, along with a "Do not ask again" checkbox. (5) Finally, there is a renaming participant registered which will discover whether an R field is renamed, so if you go and rename R.layout.foo from Java, this will also kick in all of the above machinery - renaming layout files, updating resource references, etc. If the renamed resource is in a library project, the refactoring will also look at all the including projects and offer to update references there as well. Finally, this CL goes and fixes a few bugs in the existing refactoring operations; in particular, making sure that they not only look at files in layout/ but in all folder configurations containing layout files. It also adds refactoring unit tests. Change-Id: Ie88511a571b414fdc5be048e781fe29a34063cbf
* 38994: UI designer's -> "Edit ID" should allow ID removalTor Norbye2012-10-292-0/+8
| | | | Change-Id: I7ca6454f9a698d2bcd35350e6bd324fd01eaf7d7
* Validate user edits in XML filesTor Norbye2012-09-202-8/+198
| | | | | | | | | | | | | | | | | | | | 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
* Improve last editor mode handlingTor Norbye2012-09-192-13/+13
| | | | | | | | | | | | | | | | | | | | | | | | We recently added the ability for the IDE to remember whether you last edited an XML file in text mode or in graphical mode (see issue 31340). However, this was tracked with a single boolean flag, which meant that it was an "all or nothing" flag. However, you may want to always edit string resource files with the XML editor, but you want to always use the graphical editor for the manifest file. In this changeset, the state is kept in a bitmask instead, which allows us to track the broad editor types separately. With this, new editors are opened according to the last mode you used for that type of editor. (Note that it tracks "categories" of editors, not individual resource types, so for example the editor for color resources and the editor for state list drawables share the same last mode as the string resource editor. This is because these editors share roughly the same graphical editing capabilities.) (The CL also contains some minor code cleanup.) Change-Id: I4624dffa2349230684c0558a33081adda8d799b2
* Constants refactoring.Tor Norbye2012-09-1341-584/+314
| | | | | | | | | | | | | | | | 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
* Default action for view rules.Tor Norbye2012-09-041-0/+11
| | | | | | | | For now, text-oriented widgets declare their default action to be to set the text attribute. Also hook up the default rename keybinding to setting the id. Change-Id: I14e8e06d0842759b1ac05e7e9494deb30b3cc40f
* Unify all loggers in the sdk tools.Xavier Ducrohet2012-08-171-2/+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-2/+2
| | | | | | | Move stuff out of sdklib into common and ide_common. Remove androidprefs and move the one class into common. Change-Id: I71d126a13cf2ba413692e29616f4968a37d7b33a
* Improvements to relative layout move and delete operationsTor Norbye2012-08-087-54/+340
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changeset improves the way the RelativeLayout editing support in the layout editor handles deletions and moves. First, during a move, if the move is simply within the same layout, then the layout constraints are left alone such that if you for example have A v B < C < D and you move B up to be next to A, you end up with A < B < C < D (It will however remove cycles if the move would result in them.) Second, it now handles deletion better where deleting a view will cause all references to any deleted views to be replaced by transitive constraints. For example, if you hve A < B < C < D and you delete B and C, you end up with A < D Change-Id: Icb9d3552e60aee20192f7941fe52be71ba52557f
* Refactor common.jarXavier Ducrohet2012-08-0732-39/+43
| | | | | | | | | | | | | | | 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
* Remove attributes from descriptors that are marked @hideTor Norbye2012-08-011-3/+13
| | | | | | | | | | Certain attributes in the attrs.xml file are marked as @hide via a preceding XML comment. These should be removed from the ElementDescriptors and the AttributeDescriptors such that they don't show up in code completion etc. Change-Id: I3a7428e86afe04795939d7de1a27fd1cbb2c76cb
* 26501: Handle padding between image and textTor Norbye2012-07-272-13/+2
| | | | | | | | | | The visual refactoring for converting a LinearLayout with a <TextView> and an <ImageView> adjacent into a single <TextView> using a compound drawable, needed to properly handle spacing between the two widgets. This changeset updates it to convert margins between the views into a single drawablePadding attribute. Change-Id: Idb077e3324c279d41fdc0baa68008fe862d8181a
* GridLayout bug fixTor Norbye2012-06-202-2/+7
| | | | | | This changeset fixes a bug in the vertical handling of views. Change-Id: I80896b2f6e5c4799c14c55e46e0bd90388b2901f
* GridLayout bug fixTor Norbye2012-06-121-2/+13
| | | | | | Handle baseline alignment better Change-Id: I331ebd2617612479eb686a456bd6f862f5acd7ea
* GridLayout support workTor Norbye2012-06-126-290/+696
| | | | | | | | | | | Lots of miscellaneous fixes to the GridLayout support in ADT. The changes include using the GridLayout state (via reflection) to populate the model; caching the grid model for performance, and a bunch of fixes to the code which handles insertions and removals. There are also some new unit tests. This is not done, but is an improvement over the current state. Change-Id: I4851153d3e409630c2d2024c4894d1ad1535fb47
* Add isSame on IDragElement, and sort primary to frontTor Norbye2012-06-071-1/+2
| | | | Change-Id: I7121b5f0e3714fec705387603f641bc14ed0ab3e
* 32745: Lack of warning of using duplicated IDs for element.Tor Norbye2012-06-051-1/+5
| | | | | | | | | | | | This changeset adds a validator to the assign/edit id dialog used in the layout editor such that the user gets a warning if picking an id which is already defined within the same layout. Also cleans up the Rules API for adding a validator and makes the generic resource validator handle both the case of requiring a unique name and requiring an existing name. Change-Id: Id9642c3bcd326f9734cf98c98f6799b67e11a4ae
* Fix nullness annotationsTor Norbye2012-05-3036-196/+338
| | | | | | | | | | | | | | | | | | | 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
* Improved lint integration in the layout editorTor Norbye2012-05-241-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changeset improves the lint integration in the layout editor in the following ways: - The outline now shows error or warning indicators in the bottom left corners of the icons for any specific views that have one or more lint warnings associated with them. There is a tooltip if you hover over the icon which displays the lint message. - The layout editor canvas displays little warning indicators in the bottom right corner of the views (provided the views are larger than the icons; e.g. empty layouts, as well as views that are zoomed out very far will not show lint indicators). - There is a tooltip hover in the canvas as well. In order to avoid obscuring content, it shows up at the bottom of the view. It might also show multiple lines: one for each lint warning in a view near the cursor. (This is important if you for example have a warning both on a layout and a widget inside that layout.) - The error indicator in the upper right corner, which used to be a (too small) warning icon is instead an issue count now. Clicking on the issue count opens up the lint file dialog. - The lint file dialog now contains a button to suppress issues by attributes (and fixed some other minor bugs related to keeping expanded categories expanded across refreshes and setting an initial selection). - Lint is run automatically when the layout is opened up (3 seconds after the first successful render). This makes the error indicators show up (until now, it would only run single-file-lint after the first edit operation). Change-Id: I306aca390d70bf025f5e86fc21ae7b6bc0036d8d
* Move XML code to the common libraryTor Norbye2012-05-2032-48/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Make XML code completion work for custom views & attributesTor Norbye2012-04-273-1/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | This changeset improves the custom view handling such that XML code completion offers any custom attributes (along with documentation tooltips and type information). This is done by finding any declare-styleable attributes defined in the project defining the custom view. In particular, this will also work for the GridLayout library project shipped as part of the android.support package. The fix is not tied to completion; it's improving the metadata descriptors computed for custom views, so this fix for example also makes these custom attributes show up in the property sheet in the layout editor. Finally, this changeset fixes a couple of bugs in this area: - One initialization path was not looking up custom views for unknown descriptors, this might be the fix for http://code.google.com/p/android/issues/detail?id=23020 - There was a bug in the code which looks up the namespace prefix to use for a given namespace URI: it would return the default Android prefix for some non-Android URIs. - Small performance tweak to avoid regexp construction in a loop where it's not needed Change-Id: I55dfcea6e6ea9d7c38e18a47b757678176facbd2
* Change AttributeInfo.getFormats() to returning an EnumSet<Format>Tor Norbye2012-03-224-31/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changeset changes the signature of AttributeInfo.getFormats() from returning a Format[] to returning an EnumSet<Format>. Furthermore, it defines a number of constants for the various common format sets such that they can be reused. Nearly all uses of the getFormats() method was really just trying to see "is format X among the formats", so using enumsets is more natural since it has a contains method. This also lets us replace some attribute init code which was building up a set from the array for this exact same purpose just reuse the format set directly. In the attribute parser, rather than computing the uppercase version of each format string ("dimension"=>"DIMENSION") and then doing a Format.valueOf("DIMENSION"), we now compute a map for all the format constants as lowercase to the corresponding format instance, and use that map when parsing the attrs.xml file. Note that there is a small semantic change from having an array of formats to using an enumset: The format specified an ordering. However, it does not look like any code depended on this, and it's also not clear that the ordering in attrs.xml is intentional. For example, it contains both "color|reference" and "reference|color", and in both cases the intent is that the attribute can specify an actual color or a reference to a color. Now with an enum set, the order used when traversing the formats will always be in their natural order, and for this purpose the REFERENCE type is moved to the end since it's the least specific. Change-Id: I1170cff48086f5cc13e4b70a35deea1f9979c883
* Make GridLayout support work with the support libraryTor Norbye2012-03-084-193/+197
| | | | | | | Also fix the paste operation to target the parent if the paste target does not accept children. Change-Id: Id084db376e5ff9b4a374e6d2145bc890a925a078
* Handle the android support gridlayout library automaticallyTor Norbye2012-03-081-0/+2
| | | | | | | | | | | | | | | | | | | | | This changeset adds support for the android support library's GridLayout library project. When you create a new layout with the GridLayout, or when you drop a GridLayout, the IDE checks whether you need the compatibility version of GridLayout (e.g. min sdk < 14), and if so, offers to install it. This will then first run the SDK manager to install the android support package into extras, and then it creates a local library project in the Eclipse workspace, and updates the library dependency to reference it. Finally, it rewrites tags such that the layout will use the compatibility package for the <GridLayout> and <Space> tags. This is done in the node handler, so client rule code will automatically get the right compatibility tag; they don't need to handle it there. Change-Id: I6da926eee7ffa956832ddd311d4180e8ff38ae07
* GridLayout fix: Ensure that the column count is adequateTor Norbye2012-03-011-1/+2
| | | | Change-Id: Ic1c82cae57d1ea41f54b49c3414ae526b2045ec7
* Merge "Add quick fix for the UseCompoundDrawable lint warning"Tor Norbye2012-01-261-0/+12
|\
| * Add quick fix for the UseCompoundDrawable lint warningTor Norbye2012-01-231-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changeset adds a quickfix for the "Use Compound Drawable" lint warning. That warning identifies a LinearLayout which contains exactly one TextView and one ImageView (in either order, and the linear layout can be in either orientation), and suggests replacing it by just the single TextView along with a drawable attribute. The description alone wasn't clear, so the quickfix performs the conversion automatically. In addition to the conversion it also needs to transfer any layout param references from the old LinearLayout to the TextView (and assign it an id if necessary), so the quickfix is implemented as a visual refactoring. It's also made available from the Visual Refactoring menu. This changeset also updates a couple of unrelated golden files in the refactoring unit tests to track a message change a few months back. Change-Id: Iecb544d196fdd4bcabf13a3fdb82ef1ea063f4c2
* | Fix RelativeLayout margin feedback: convert from px to dpTor Norbye2012-01-231-1/+2
|/ | | | Change-Id: Idf39c08f8970161ecf63d12745cb6ad34e84ec61
* Fix locale handling of uppercase/lowercaseTor Norbye2012-01-062-5/+10
| | | | | | | | | | | | | | | | | 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
* Merge "Set android:ems="10" for EditTexts on drop"Tor Norbye2011-12-222-0/+7
|\
| * Set android:ems="10" for EditTexts on dropTor Norbye2011-12-222-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Text fields (without a text attribute) has by default only a single character visible. To work around this, we automatically set the layout_width to match_parent instead of wrap_content in LinearLayouts, but in RelativeLayout and GridLayout etc (and in general) we don't have this, so text fields show up with a not particularly usable size. By setting the ems attribute to 10, the wrap_content size of the text field will show 10 characters which seems like a reasonable default (and when editing the XML or properties it's more obvious what you'd want to modify to get a different size, if not match_parent. Change-Id: Ic0460cea7810076b416f6d7d25a683851465ee9b
* | Add textfield to resource chooser for @string resourcesTor Norbye2011-12-221-1/+2
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changeset adds a new textfield to the bottom of the resource chooser in some scenarios, such as when editing @string resources via Edit Text in the layout editor. This text field updates to show the @string/resourceName value whenever you update the selection in the filter, but it also allows you to edit the text to anything else, such as a literla String (not a resource). This makes it easy to edit simple labels. See the following adt-dev thread for some background on this: http://groups.google.com/group/adt-dev/browse_thread/ thread/d53e71c2970ce369?pli=1 There is also a new label below the text field which shows the "resolved value". For example, if you've chosen "hello" in the filter list, the new value text will show "@string/hello", and the new label will show "Hello World". This will hopefully make it more obvious what it is you're editing. And, similar to the widget render preview for drawable resources, this makes it easier to browse and pick labels, especially when browsing framework resources. This is currently only enabled for @string and @dimen resources, but we could conceivably add it for other resource types too. Longer term, we need inline editing of widgets (where values entered automatically get translated into resources), but this is a stopgap measure which makes it easier to build simple apps quickly, and which still makes it simple to create new strings or select existing ones from the filter list. (And we have both Lint and the Extract String refactoring to help identify and fix hardcoded strings later on.) While working on this I also discovered the root cause for this bug: 20589: The reference chooser is not usable for framework styles Turns out org.eclipse.ui.dialogs.AbstractElementListSelectionDialog has a handleEmptyList() method which calls setEnabled(false) on the filter list when the list is empty. Crucially, there is no corresponding setEnabled(true) call when the list is made non-empty! When the user switches between framework and project resources, the list is temporarily empty, so the list gets disabled, and that's why it's not responding to menu clicks at all. This changeset also fixes that bug. Change-Id: Id441104d617fa4440daba3da2dc63e2c999f48c1
* Update SDK codebase to JDK 6Tor Norbye2011-12-2117-0/+53
| | | | | | | | | | | | | | | | | | | | | 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
* Don't assign ids to all newly dropped widgetsTor Norbye2011-12-191-1/+3
| | | | | | | | | | | | | | | This changeset makes the layout editor no longer assign default id's to all newly dropped widgets. In particular, it no longer assigns id's to *Layout widgets, such as LinearLayout and RelativeLayout. These id's are typically unused, and in the case where you do want an id to manipulate the widget you probably want to change it to some more logical name than "linearLayout1" anyway. (It also stops assigning id's to <include> tags, <merge> tags and <Space> widgets.) It also changes the label of the "Edit ID..." context menu action to "Assign ID..." for widgets that do not currently have an id. Change-Id: Ibf0ec25a6a687e34d3eebf828251d196cadb9d54
* Add new detectors for layout parameters and deprecationsTor Norbye2011-11-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | This changeset adds two new detectors: (1) An "obsolete layout parameters" detector which finds cases where the layout parameters on a view do not match the current parent view. This usually happens when view XML is copied and pasted around, or layout hierarchies are changed, without the views themselves getting updated. The detector also tracks include tags and checks that tags are not only consistent within their own parent, but that root tag layout parameters and <merge> tag children are also consistent with their usages across <include>'s. There is also an Eclipse quickfix for this warning. (2) A deprecation detector. This currently only warns about AbsoluteLayout. Change-Id: I714e8a0d2a614ea4ee3fd5c7b60d012f18567169
* Support for custom view rule jarsTor Norbye2011-11-151-78/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | The layout editor already supports providing a classpath of jar files to check for custom views (via the layoutrules.jars property in project.properties). However, once a view rule has been initialized it is never updated. This changeset makes the view rule loader more dynamic, such that it checks the file timestamps of the jar files, and when the jar files are changed it unloads the old rule instances and creates new instances. This makes it a lot easier to develop view rules since you can just update the .jar file and the layout editor automatically picks up the changes (within a couple of seconds; for performance reasons it checks the filestamps at most every couple of seconds (and this is only done lazily of course, so there isn't a file change listener; it just makes sure that if rule loading requests come in more frequently than that it just uses the current class loader). This changeset also adds an AbstractViewRule which implements the IViewRule interface. Without this, implementing a custom view rule will require dozens of methods to be stubbed out (and for the developer to figure out what the methods are and what to do with them). Change-Id: I5f2b84e32e47611fff2d4211411f3039d16eb815
* Fix issue 21348: Don't set android: namespace on fragment classTor Norbye2011-11-011-0/+6
| | | | Change-Id: I388bf2cef04bb113be2440901ffaa06f7a95b92f
* Misc GridLayout handling fixesTor Norbye2011-10-263-59/+152
| | | | | | | | | | | | | | | | | | | | | | | | | | This changeset fixes some miscellaneous in the GridLayout support. The gravity handling code (which creates a bitmask for gravity from XML attribute values) was pulled out of the change layout refactoring such that it can also be used by the GridLayout. This is done to figure out where cells are not bound to the top or left corners, in which case they should not be considered when computing a suitable right or bottom edge for splitting a cell. There's also fixes for a problem where certain negative constraints would be offered, there were tooltips when only one of the two dimensions produced suggestions (and you can only drop when both are valid). When removing children back to a blank layout, reset the columCount to 2. And finally there were some problems where the columnCount was larger than the number of actual used columns in the table, where dragging near top/left corner would use some of the later columns rather than the first available one. Change-Id: Ice22754fb14659812b54019452aeca6daaeede10
* More lint checks: translation, i18n, proguard, gridlayout, "px"Tor Norbye2011-10-201-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changeset adds more lint checks: (1) Translation. It looks at all the string values in the application, and if there are discrepancies (where a translatable string is not defined in all provided languages and regions) then these are listed. (2) Internationalization. It looks for text: and contentDescription: attributes and ensures that these refer to @string resources, not hardcoded string values. This lint warning also has an associated quickfix when shown in Eclipse which invokes the Extract String refactoring wizard on the right selection context. (3) Proguard. It looks for the old (broken) patterns we had in older proguard.cfg files (-keepclasseswithmembernames instead of -keepclasseswithmembers which implies shrinking.) (4) GridLayout. It looks at the layout constraints provided on views in a GridLayout and ensures that they fall within the overall dimensions of the grid. (5) "px" usage. It looks for dimensions using "px" as a unit and recommends switching to dp instead. This lint warning also has a quickfix in Eclipse which pops up a dialog asking for the screen density and then converts the px value to the right dp value and changes the unit. (6) TextFields. It looks at EditTexts and makes sure they either set inputType, hint or inputMethod. There's a quickfix in Eclipse for setting the inputType, which adds the property and automatically invokes content assist for showing the possible values. This changeset also adds some quick fixes for a few existing lint warnings: (7) Accessibility: Insert a content description attribute, front the editor and select the placeholder value. (8) Useless leaf layout: Remove the leaf layout (9) Useless middle layout: Invoke the Remove Container visual refactoring 10) Inefficient Linear Layout Weights: Change the attribute to 0dp Plus unit tests. Change-Id: Iebd7b23224a898bd1851abd578460019aee44df5
* More GridLayout FixesTor Norbye2011-10-103-35/+120
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changeset fixes various issues in the GridLayout support: (1) Add custom Paste support for GridLayout. The default copy/paste handler just treats a paste as a drag into (0,0) followed by a drop. That doesn't work well for GridLayout since it ends up writing the dragged elements into row/column 0,0. This changeset adds a custom override of the paste handler such that it adds the pasted elements into successive table cells instead. It still needs to adjust the column spans to avoid changing the current table structure; that will be done in a followup CL. (2) Clean up the Layout Actions Bar a bit for GridLayout. Separate out the "Show Structure" and "Grid Mode" actions, and make grid-operations (Add/Remove Row/Column) only show up in Grid Mode, and similarly only show Snap to Grid in Free Mode. (3) The hidden <Space> widgets should also be hidden when selected via Select All. Also fix a remaining issue with the action enablement of Select All. (4) Fix a bug where the preview bounding rectangle was drawn at the wrong place when showing a center-horizontal proposal. (5) Remove an assertion encountered during GridLayout conversion which is not always true. Change-Id: I8c4c0cac5052e59c5943e535b2f790f420303f9d
* Update GridModel to track GridLayout changeTor Norbye2011-10-061-2/+2
| | | | Change-Id: Idc4a9af22a54634d5999b3732713e705c0506df8
* 20542: Contextual prop menu doesn't work well for textStyleTor Norbye2011-10-051-1/+14
| | | | Change-Id: I34769f28848cd4618611db1a18f719466d3b1c1e
* Grid Layout and Convert to Grid Layout improvementsTor Norbye2011-09-283-6/+74
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | First, some improvements to Grid Layout handling: (1) When dropping a new widget, look up the sizing metadata and use it to determine what fill gravity to set. For example, a button will use gravity left, and a text field will use gravity fill_horizontal. (2) Don't warn about reflection problems when failing to find GridLayout layout data; this probably means the layout is being attempted opened in an unsupporting SDK. There's a fallback case to compute the data instead already. Second, improvements to the conversion to GridLayout handling: (1) It now looks at the layout_gravity values to see whether each row and column is flexible, and if there's no flexible column in each of the horizontal and vertical dimensions, it will insert a special <Space> element to absorb any available extra space. This avoids constraints warnings from GridLayout. (2) It treats layout_width or layout_height attributes of match_parent or fill_parent as the same as a fill gravity (and removes it) and uses this in the flexibility computation above. (3) It removes unsupported layout params for all children (earlier this would only remove unsupported layout params on the direct children of the layout, which isn't enough when a hierarchy is being flattened.) (4) It's smarter about computing implicit rows and columns, so it avoids writing out redundant layout_row and layout_column attributes in some cases. (5) It avoids throwing refactoring errors in cases where an attribute is removed twice (6) Fixes a bug where the root layout was included when computing the set of used x and y coordinates, which means you'd often end up with a blank row and column 0. (7) Various refactoring to make the code cleaner. (8) More unit tests and updates to existing unit tests to reflect the new behavior such as an absorbing spacer and removal of redundant attributes. Change-Id: Iee44c3ca749eefc107b83545669cc9d7f84615b1
* Merge "Misc GridLayout interaction fixes"Tor Norbye2011-09-083-5/+30
|\