aboutsummaryrefslogtreecommitdiffstats
path: root/eclipse/plugins/com.android.ide.eclipse.tests
Commit message (Collapse)AuthorAgeFilesLines
...
* New Project Wizard overhaulTor Norbye2011-09-134-392/+45
| | | | | | | | | | | | | | | | | | | | | This changeset splits the New Project Wizard into multiple logical wizards (a separate one for samples, testing and plain projects), and each wizard contains multiple pages - such as a separate page for SDK selection, a separate page for Sample selection, a separate page for Test target selection, and so on. In addition, sample projects are now copied into the workspace itself such that they can be modified and deleted without affecting the mater copy in the SDK install directory. Samples can also be accessed from a new separate entry in the New wizard. The SWT code is now maintained with WindowBuilder. Most of the code in NewProjectWizard was related to actually building the projects, and this code is preserved in the new NewProjectCreator class which is used by unit tests etc such that we don't need to create a stub wizard and stub wizard page anymore. Change-Id: I64872722e320a109870403d25fdf051270b526ed
* Fix build of ADT tests.Raphael2011-09-081-5/+6
| | | | Change-Id: Ie1627d420c862dceff2197639f4006f61f7442c2
* Support for palette configurations in Change Layout RefactoringTor Norbye2011-09-072-0/+44
| | | | | | | | | | | Some items in the palette are just variations of other items with some different initial attributes. The Wrap In refactoring already supports these, but the Change Layout did not - so for example converting to a Vertical Linear Layout would not set the orientation="vertical" attribute. This changeset adds support for these in the change layout refactoring as well. Change-Id: I9b44a57ebf5cddba7ae381b48b666e53f7f41ab0
* Add/Remove wrap_content when converting GridLayoutsTor Norbye2011-09-0710-37/+148
| | | | | | | | | | | | | | | | | | In GridLayout, the layout_width and layout_height attributes use wrap_content by default. We already avoid setting these on the elements themselves when dragging into the layout, but this changeset makes the Change Layout refactoring remove wrap_content attributes when converting to GridLayout, and adding them when converting from a GridLayout. When changing layouts, any layout params that are supported on the old parent layout, but not the new layout, are removed. However, this was not done for the non-layout attributes on the parent layout. This changeset also fixes that bug, so for example after converting a horizontal LinearLayout to a RelativeLayout, the "orientation" attribute is removed. Change-Id: Id25b80b567578bd5882c527bbe23115577ff7d61
* Merge "Misc New Project Wizard fixes"Tor Norbye2011-09-061-0/+7
|\
| * Misc New Project Wizard fixesTor Norbye2011-09-061-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changeset fixes a couple of bugs in the New Project wizard: (1) It escapes strings, such as the application name, in the strings.xml file. http://code.google.com/p/android/issues/detail?id=6725 (2) It fixes package name validation in the activity name http://code.google.com/p/android/issues/detail?id=14811 (3) It selects an SDK target by default http://code.google.com/p/android/issues/detail?id=17505 Finally it also ensures that the suggested activity name is a valid Java class name even where the application name is not. Change-Id: Iba9843dbb2fbb09324122d285e51ad937f6fddfd
* | Formatting fixes for color listsTor Norbye2011-09-061-4/+20
|/ | | | | | | | | | | | Color lists ended up getting formatted using the generic layout style instead of the resource style (with multiple attributes packed into the same line). Furthermore, by convention the "color" attribute always logically sorts to the end, after the various state flags, so update the attribute sorting rules to reflect this. Change-Id: Iaa88106f7eaf7c953b3a97dc203da5833a3bf085
* Merge "Add GridLayout support to the ChangeLayout refactoring"Tor Norbye2011-09-064-1/+219
|\
| * Add GridLayout support to the ChangeLayout refactoringTor Norbye2011-09-024-1/+219
| | | | | | | | | | | | | | | | | | | | | | | | | | This changeset adds a generic-to-GridLayout converter to the "Change Layout" refactoring. The converter arranges the views into a grid based on their bounds, uses the sizes to determine row and column spans, and then writes this out as the resulting grid. Note that it does not yet consider existing layout knowledge to add better constraints, such as gravity, or arranging vertically overlapping views in a horizontal row into a same shared row. Change-Id: I78e5fdf49d9e2a838a7229e2e31aa62e190032ad
* | Escape string in "extract string" refactoringMichael Zoech2011-09-021-0/+57
|/ | | | | | | | | | | | | When executing the "extract string" refactoring only single and double quotes are escaped correctly. This patch for the bug #19612 improves the method by escaping the following characters: * Spaces at beginning or end of string. * @, ? at beginning of string. * ', ", \, <, &, \n, \t anywhere in string. Change-Id: Ia2939213bd5460399dc5e19f5ce413c3f5812ea8
* Add support for remaining asset types in Asset Studio WizardTor Norbye2011-09-012-0/+28
| | | | | | | | | | | | | | | | | | | | This changeset ports the remaining graphic generators from the HTML5 version (notifications, tabs, action bar), and hooks up wizard support for them. It also adds unit tests for the generators which generates images and compares them to known good versions. I ran these tests comparing them to the output from the HTML5 version of Asset Studio and all but 3 of the images varied less than 5% (and I verified the remaining manually and they're all fine and the difference is due to the images being aligned slightly differently.) The icon wizard is now also hooked up to the "New" button in the Resource Chooser for drawable resources, and this changeset also fixes a few related issues ("New" didn't work for file-based resources, and newly created resources weren't showing up in the selection list.) Change-Id: I48c49f1d5de452aa5b78e491d9b07e7156397fa9
* Use GridLayout state to determine exact row and column boundariesTor Norbye2011-08-234-5/+5
| | | | | | | | | | | | | | This changeset updates the GridLayout support to consider the state of a rendered GridLayout when deciding where the rows and columns are. This information is already available in the GridLayout object, so if one is provided use that data rather than inferring it from the bounds of the views in each row and column. This required changing the view rules API a bit to pass the view objects in to the key entry points (drawing selection, drag & drop and resize). Change-Id: If8484f7f7181c65d0a2fdf629ffd515edd05448b
* Misc refactoring and test fixesTor Norbye2011-08-2341-159/+1100
| | | | | | | | | | | | | | | | | | | | | This changeset turns on automatic formatting of the affected regions in extract include, change layout, wrap in and style refactorings. It also fixes a couple of minor bugs - one handling empty tags in the change widget type refactoring, and one handling selection offsets. It also turns on automatic formatting of GUI editor changes (there was a previous changeset which prepared for this but forgot to actually switch the default option.) This changeset also makes various test infrastructure fixes: code completion tests recently stopped working for a number of files (something about the initialization order of editor types when running as tests). I also tweaked the goldenfile format of the diffs to avoid trailing diffs on lines with just a ">" or "<" since gerrit makes thee light up in red. Change-Id: I78b858f0b21e5b2f25a9566ad495bad09c66a18f
* Add Unwrap RefactoringTor Norbye2011-08-197-0/+148
| | | | | | | | | | This changeset adds a new visual refactoring: "Remove Container". This is basically the reverse of the "Wrap In" refactoring (which surrounds the selected views with a new parent layout). Instead it takes a parent and removes it, in the process transferring the namespace declaration (if a root element) and any layout params to the children. Change-Id: Id535b88fcf39a8b7a83fd6feb981fff000140e8a
* Layout editor property menu improvementsTor Norbye2011-08-196-38/+182
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changeset adds two forms of view attribute metadata: * First, it records the most commonly used attributes for each view. This was determined by gathering statistics on as many layout files as I could find and then picking those that are used 10% or more. * Second, it records in the attribute metadata which View defines a given attribute. The context menu uses the above information to present the available attributes in several ways: * In the top level menu, where we had "Edit ID", and if applicable "Edit Text", it now lists the top attributes instead. For example, for a RatingBar the first handful of menu options are "Edit ID...", "Edit NumStars...", "Edit StepSize...", "Edit Style..." and "IsIndicator" (a boolean pull-right menu). Incidentally this automatically handles some cases which were manually handled before, so the code in LinearLayoutRule to add an "Orientation" menu is no longer needed; it's just one of the two common attributes handled by the new attribute list. * The "Properties" menu is now called "Other Properties", and instead of showing all properties, it has a new level of menus: * "Recent". This is initially empty, but as you edit other attributes, it gets populated (in most recently used order, kept up to date) with recently edited properties. * One submenu for each defining View super class listing exactly the attributes defined by that view. This is useful for browsing and editing related attributes. If you are looking at a textual view like a Button for example, you can look at the "TextView" menu to find all the text related options (TextColor, TextSize, etc). These menus are listed from the nearest to the further superclass, so for example if you right click on a CalendarView you'll see these menus: Recent > ---------------------------- Defined by CalendarView > Inherited from FrameLayout > Inherited from ViewGroup > Inherited from View > ---------------------------- Layout Parameters > ---------------------------- All By Name > * As you can see from the above, there are two more menus below the inherited menu items. "Layout Parameters" lists all the layout parameters available for the selected nodes (which is defined not by the view itself but the view that it is contained within). And finally there is "All By Name", which is a complete menu containing all available attributes for the view (and this is what the Properties menu used to contain). * The code which computes a display name from an attribute was also tweaked to capitalize not just the first letter but any first word letter, so for example when you look at the possible values for Gravity you now see "Clip Vertical" instead of "Clip vertical". * The edit property dialog for the properties menus now uses @string or @style resource choosers for the text, hint and style attributes (used to just be a plain text box.) Change-Id: I3b30d48b85fd13f0190c760756bf383a47b3f4a5
* Fix and turn on the auto-format XML optionTor Norbye2011-08-191-1/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changeset turns on the option to "Automatically format the XML edited by the visual layout editor" by default. It also fixes several issues related to it: - First, the auto-format code was previously hooked up to synchronous insert and delete node events, which meant during a larger edit it would apply formatting repeatedly and before the edit was complete (which made the DOM model keep reparsing to update document based back into its internal model). - Another problem was that the auto format only applied to added and removed nodes; attribute edits were not considered (which made sense given that the old formatter did not support reordering of attributes, but now that it does attribute changes requires reformatting as well.) - The old reformatter was trying to work with the Eclipse XML formatter, which does not handle partial document formats well (there were a bunch of workarounds, and even with those there were some problems). The new formatter does not, so I've changed the option to be tied to the custom formatter; the automatic formatting of layout editor changes is now enabled only when the custom editor is enabled. This also takes advantage of the new formatter's ability to only format the attributes section of a document, so if you just tweak the attribute of a node, the children's formatting is not affected. - The formatter would apply to more than just the layout editor; any UI editor which used UiElementNodes would be affected. I've added a method, by default false, where each UI editor can opt into this. I'd like to get Raphael's feedback on the manifest editor before possibly adding it for that editor as well (and updating the option name to something more generic). - The mechanism for ignoring XML document changes (already used for refactoring) is now also connected to reformatting, so when the formatter runs it sets an "ignore" flag such that there is no second XML model loading when the changes are just as a result of a formatting option. This changeset also tweaks the formatting behavior of comments; instead of -always- adding a blank line before line comments (other than suffix comments), it now considers the previous document and preserves the spacing used there (though it will collapse multiple lines into one). Change-Id: I04c2b80836c4d9874dca789c2f2cbc8c8c7cfa76
* Make smart indent handle whitespace indentation betterTor Norbye2011-08-191-0/+141
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The smart indent implementation handles indenting within element content (e.g. between tag names and attributes) and at element boundaries (e.g. before and after <>'s.) For other parts of the document it just defaulted to the normal XML smart indent. However, this includes handling newlines within blank space. This changeset adds special handling for some key scenarios: Indent the newly inserted line depending on the surrounding context: <foo> <foo> | ====> </foo> | </foo> Also subtract whitespace on the right hand side of the cursor when necessary: <foo> <foo> | <bar/> ====> </foo> |</bar> </foo> There are some other cases as well, described in the unit tests. Change-Id: I8e679800fe56cae598f430b6f6de409309407708
* Use Eclipse XML parser instead of JDK parser when formattingTor Norbye2011-08-181-38/+5
| | | | | | | | | | | | | | This changeset adds a utility method which parses an XML string using the Eclipse structured model instead of the JDK parser. The resulting document has some extra metadata which the XML formatter can use. In particular, it distinguishes between empty tags and tags without children. Now that this is fixed the formatting on project creation code includes manifest files, which I excluded previously because it made the <uses-sdk> element look ugly. Change-Id: I7069fa43df33d874303435b3625f1c7b20f5b3d3
* Add missing qualifier iconsTor Norbye2011-08-171-1/+1
| | | | | | | | | The Available Width, Available Height and Smallest Width qualifiers were missing icons (which are shown in for exmaple the Create Configuration dialog). This changeset adds icons for these (which also makes ResourceHelper.testGetIcon pass.) Change-Id: I42c4e357245adc0b80320bac5fe1e173d1d0eaf3
* Pull View Rules API into a separate libraryTor Norbye2011-08-151-0/+1
| | | | | | | | | | | | This changeset pulls out the API classes from the plugin sources and into a separate standalone .jar library. The library depends on the common.jar library. With the separate view API it should be possible to build designtime helpers (view rules) for custom views to improve editing behavior in the layout editor. Change-Id: I20bb511668de2fe52910e5fe0bbd3ec2a18b5a08
* Action API improvementsTor Norbye2011-08-151-26/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changeset changes the Actions mechanism for view rules to add support for the following: * Delayed computation of submenu contents. Before this, a view rule would have to produce the full tree of actions to be shown in menus and submenus - for example including all the properties, and in turn all the enumerated values for those properties and so on. Now there's a Provider interface which can be used to compute these menu items only when the menu is actually opened. The properties menu now takes advantage of this. This was also necessary to implement the following new feature: * The layout editor context menu now also lists not just the properties for the currently selected views, but also the properties for the parents. For example, if you open the context menu, you'll see the properties for the button you just right clicked on, but there will also be a "frameLayout1" submenu containing the actions for the <FrameLayout> parent of the button, and a "linearLayout1" submenu for the parent linear layout. This is useful when a parent layout doesn't have blank space on its own so it is difficult to target. A future CL will use the lazy initialization to add more options to the properties menu. * Support for arbitrary nesting. Submenus can contain submenus can contain other submenus etc. * Custom ordering. This changeset moves the "sort priority" concept (which was already used for layout actions) up to all actions, which makes it easier for rules to cooperate on ordering because instead of appending or prepending to the superclass' context menu result, actions can now just be initialized with a sorting priority value which makes it trivial to interleave actions regardless of who adds them. This also makes it a lot easier to use custom ordering in choice menus where the ordering used to be alphabetically sorting on keys. * Improved support for multiselection. The callback interface now takes a list of nodes to apply the callback to, and actions can indicate whether they support multiple nodes. This makes it possible for actions to more directly support the case where you apply an action to multiple nodes. As before, the available actions in the context menu is limited such that it only shows the actions common to all. But now those actions can do something specific. For example, if you select "Edit Text..." on many nodes, you will get the input-string dialog once, and then the value is applied to all. Similarly, if you select "Edit Id..." it will ask for a separate id for each value (and you can cancel out of this loop). There are various API changes too. Since the Choices action (which had a map-based set of values) was removed, the OrderedChoices is now renamed Choices. The Actions subclass of MenuAction which all actions also extended has simply been moved up to the top level MenuAction. And MenuAction has been renamed to RuleActions since they are used not just for menus but for toolbars etc and the key thing about this interface is that they are intended for use by rules. Change-Id: If49f75213f2041ebfef7e84254d70d219bb766ab
* Fix a few XML comment formatting corner casesTor Norbye2011-08-111-3/+34
| | | | | | The cases are covered by the new unit tests. Change-Id: I165def59dad59de7e8e1c4e5516c567722aa254e
* Improve partial XML formattingTor Norbye2011-08-101-5/+16
| | | | | | | | | | | | | | | | | | | | | | | This changeset improves the behavior of the formatting when formatting just a part of the document (e.g. the selected region, or more accurately the nodes overlapping the selected region.) First, it looks up the current indentation levels in the document of the start node and its parent and uses that for the indentation, which means that nodes appear to be pretty printed in line instead of jumping to whatever the absolute indentation level would correspond to. Second, the formatter now has a mode where it can format only the opening tag of an element. This is a special case of formatting a node which is particularly useful when you enable automatic formatting by the layout editor, since just setting a property on a root element shouldn't reformat all the element children of the edited node. Third, there are various tweaks to how the whitespace is handled around the inserted node. It also fixes a couple of bugs. Change-Id: If1dd2dc5091a08b770927cd4b9fcafe0c032a216
* Merge "Ability to suppress rendering fidelity warnings"Tor Norbye2011-08-101-2/+28
|\
| * Ability to suppress rendering fidelity warningsTor Norbye2011-08-081-2/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If you're working with a custom component that uses unsupported graphics operations, the layout editor will show an error area. This error is always there. That can be annoying since there's nothing you can do about it after reporting a bug. This changeset adds the ability to suppress these errors for the current IDE session. It adds a "Ignore" hyperlink next to each fidelity rendering error message, and when you click it, the specific type of rendering error is suppressed and hidden for the current IDE session. These warnings are only suppressed for a single session and not permanently. This is because you are suppressing an error not for a specific layout but for any occurrence of that error. If these ignore settings were persisted you might open some unrelated layout in the future and be puzzled why it does not look right. Change-Id: I2d20a36aee7767257b16ad805b0e8da36a6eb97e
* | Merge "Fix linear layout and frame layout unit tests"Tor Norbye2011-08-093-13/+12
|\ \
| * | Fix linear layout and frame layout unit testsTor Norbye2011-08-053-13/+12
| |/ | | | | | | | | | | | | | | | | I changed the code which draws drop feedback recently to use a more efficient call (calling drawRect(x1,y1,x2,y2) directly instead of constructing a new Rectangle object and calling drawRect(Rect). Some golden files checking graphics output needs to be updated. Change-Id: I369fed9cb0756ff4f3aa970c1bdd552d0f55faaa
* | Merge "Miscellaneous XML formatting fixes"Tor Norbye2011-08-051-15/+219
|\ \ | |/ |/|
| * Miscellaneous XML formatting fixesTor Norbye2011-08-041-15/+219
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changeset contains a number of tweaks to the XML formatter: - Handle "end-of-line" comments, such as those seen in some drawable <selector> files: <item android:state_pressed="true" android:color="#ffff0000"/> <!-- pressed --> <item android:state_focused="true" android:color="#ff0000ff"/> <!-- focused --> <item android:color="#ff000000"/> <!-- default --> Here the comments will continue to live on the same line as the end tag. - If the unformatted XML had a blank line between a comment and the next element, then insert a blank line there in the formatted XML as well - Always place the xmlns: attribute on the same line as the opening element tag - In alphabetical attribute sorting, make xmlns: attributes an exception and always sort them to the front just as is the case for logical attribute sorting - Fix some cases where turning on "remove all lines" would still leave some blank lines, such as in front of the root element closing tag and around comments - Fix unit tests such that they run with the default values for the formatter; they were accessing an uninitialized AdtPrefs instance (since they are not running as plugin tests) and were inadvertently just using "false" for all the flags. - Add more unit tests. Change-Id: I537f8afe4ca4d775b5f91574b895ba90a2741f5c
* | Fix some UT.Xavier Ducrohet2011-08-041-0/+18
|/ | | | Change-Id: Ia3ca9ef68d6435a323959913a6bd9298e9bcf0c9
* Add tag-handling for Go To Matching in XML documentsTor Norbye2011-08-031-0/+144
| | | | | | | | | | | | | | | | Eclipse has a Go to Matching feature, bound to Ctrl-Shift-P. However, for XML documents it only works on the character level, so if the caret is inside a tag it does nothing, and if you place it on an angle bracket, it just jumps to the opposite angle bracket for the same tag. This changeset adds a new character pair matcher which works at the tag level, so if you for example place the caret anywhere in an end tag, it will highlight the first character of the opening tag, and if you jump it will jump to that opening tag. Similarly, if you place the caret next to the < or tag name of an opening tag, it will jump to the closing tag. Change-Id: Id25487b24616abf79c71de5eec21f8c0f07e68cc
* Improve smart-indent handling in XML filesTor Norbye2011-08-032-0/+297
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changeset adds a new "auto edit strategy" for Android XML files, which replaces the default XML auto-indenter (which just copied the indentation of the previous line.) The new indenter instead uses the lexical information to indent based on the tag and bracket balance. For example, if the | represents the caret position, then the following shows how the edits are transformed: <foo name="value"/>| => <foo name="value"/> | <foo name="value">| => <foo name="value"> | <foo <foo attr1 = "value1"|> => attr1 = "value1" |> <foo <foo attr1 = "value1"/>| => attr1 = "value1"/> | It can also modify the text after the caret, as in the following transformation: <foo>|</foo> => <foo> | </foo> See the unit test for more cases. Change-Id: Ia99ecf6573ff4a9473970aa2fd481d2228ddf45d
* Merge "Use Windows line delimiters on Windows"Tor Norbye2011-08-031-2/+20
|\
| * Use Windows line delimiters on WindowsTor Norbye2011-08-021-2/+20
| | | | | | | | Change-Id: I33094888432214fc5c70c4c4392d8afd932a3a7a
* | Update tools/ADT to rev 14.Xavier Ducrohet2011-08-021-2/+2
|/ | | | Change-Id: Id29498fde61185a63812b7267b64560a8fd54dc5
* Add a new XML formatter, new options, and format on saveTor Norbye2011-08-012-0/+316
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changeset adds a custom XML formatter for the Android XML editors. There is an option for turning off this formatter and using the standard XML formatter instead. The new custom formatter offers the following features: * By default, it formats files following the Android conventions for XML formatting. This means not only that it indents with 4 space characters (instead of the Eclipse default of one tab character), but it places attributes on a line of their own, it adds blank lines in certain places, and so on. * It sorts attributes (logically, alphabetically, or none) * It formats files with different styles depending on the context. For example, in layout files it always places a single blank line between view elements, whereas in manifest files it only places blank lines between elements of different types such that for example the <uses-permission> elements all form a logical group, separated from <uses-sdk> and so on. The fact that strings.xml and layout.xml are usually formatted with different flavors is one of the reasons setting up the old Eclipse XML formatter to do the right thing was not possible. In addition, there are various user options added to the Editors preference page where you can tweak the behavior of the formatter, such as turning off blank lines completely, controlling whether there is a space before the > or /> closing characters, and you can also tell the formatter to use Eclipse's indentation setting (indentation size and whether to use spaces or tabs). Finally, there is a new "Format on Save" option which behaves just like Format on Save for Java files: when you press Ctrl-S to save a file, the XML content will be formatted before the file is saved. Change-Id: Ic6f05c768ab063b09f6f0248f60fbe8722fb149d
* Add Java Quick Assistant for Extracting StringsTor Norbye2011-07-293-6/+7
| | | | | | | | | | | This changeset adds a Quick Assistant to Java files in Android projects, which proposes "Extract String" when the caret is within a String literal. It also moves a couple of utility methods from the Hyperlinks class to the AdtUtils class. Change-Id: Ica5ff40e32e3e145481d6c895178109289ed1d9b
* Merge "Style: space after synchronized (object) {...}"Raphael Moll2011-07-291-2/+2
|\
| * Style: space after synchronized (object) {...}Raphael Moll2011-07-271-2/+2
| | | | | | | | | | | | | | | | For keywords such as if, for, while, we put a space between the keyword and the expression. Same should go for synchronized (object) {}. Change-Id: I5b145912f9346e3f4d8367865c2729abea68fdbc
* | Merge "Sort XML attributes logically"Tor Norbye2011-07-271-1/+4
|\ \ | |/ |/|
| * Sort XML attributes logicallyTor Norbye2011-07-141-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changeset modifies the layout editor such that it writes attributes in a certain order: * id * style * layout_width * layout_height * other layout_ attributes, sorted alphabetically * other attributes, sorted alphabetically The layout editor will produce attributes in this order when - New widgets are dragged into the layout - Widgets are moved in the layout - It will also insert attributes in the right place when they are set as the result of (for example) using the context menu actions. Note that this ordering is applied unconditionally - there is no user setting to turn it off. However, note that the current behavior is random - moving a view for example will scramble the attributes (in an order which is related to hashkeys in a map), so the option would be "sort attributes logically" versus "sort attributes randomly"; if we want an option to "leave attribute order alone" that will need to be implemented. Limitations: - This does not yet modify the formatter to reorganize attributes. Thus, Ctrl-Shift-F to reformat the XML will not change attribute order. - It does not fix the problem that the XML model updater does not respect the formatting settings (such as one newline per attribute) when manipulating attributes. This will be addressed/worked around in subsequent CLs. Implementation Note: The Eclipse XML model updater will unconditionally *append* any new attributes. We take advantage of this to perform attribute sorting by ensuring that we always insert new attributes in the right order. We also check for existing attributes and any which fall lexicographically later than the new attributes are removed and reinserted in the right sequence. In order to avoid performing these removals and additions repeatedly on a node when we set multiple attributes, and to avoid flushing attribute changes *immediately* (which was the case until this), we now queue up all pending attribute values in the nodes and apply them at the end when all attribute changes for a given node are known. Change-Id: If39f8c29f26e281f7c6622a31e11ba49724d274a
* | Fix code completion handling for text selectionTor Norbye2011-07-2615-10/+149
|/ | | | | | | | | | | | | | | | | | | | | | | | | | This CL fixes 18607: ADT 12 problems with xml files The bug is that if there is a text selection and you invoke code completion and select an alternative, the wrong number of characters is deleted as part of the replacement. The fix is simple: remove the code which adds in the selection count from the replacement string, since the complete replacement count is now already computed properly without regard for the selection (we should -always- replace the complete value token, not just the selection). Most of the diffs actually pertain to new unit tests for this because the testing infrastructure needed some changes to handle references to selection ranges rather than just caret offsets. There are also a couple of updates to some test goldenfiles unrelated to this fix, which updates the golden files to reflect recent changes like the package name of GestureOverlayViews and the @attr resource type in completion. Change-Id: Ie4f680f201930414457a79846f722db6efc89f93
* Grid Layout Support.Tor Norbye2011-07-114-0/+93
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changeset adds basic support for grid layouts: - Freeform mode where you can drag & drop anywhere in the layout, and guidelines are offered to align with other left boundaries, right boundaries, baseline vertical alignment and center layout horizontal alingment. In addition, it also offers "preferred spacing" positioning, using the recommended distance between widgets. Also, during a drag a regular 16x16 grid is also (faintly) shown and (when there are no alignment matches as explained above) the position snaps to this grid. We also show the grid-structure (rows and columns, not the regular snapping grid) during drags to make it more obvious that behind the scenes there is a grid (because some other operations might shift rows and columns so it's important to present the right user model.) The freeform grid layout editor will automatically create rows and columns and size them using spacers which are hidden from the user, and on deletion these are automatically cleaned up as well. - Grid mode where you can drag to any given cell, or between any two rows or columns. - Some layout actions for manipulating the grid (add/remove row and column, adjust the gravity, toggle modes.) This CL also contains various diagnostics code for the grid mode, and does not yet correctly support dragging multiple views simultaneously. Change-Id: Ie9ec54805039645e3db78d19095da86b04e44ca0
* Fix locale handling of linear layout weightsTor Norbye2011-07-071-1/+20
| | | | | | | Fix 18298: ADT r12 layout editor uses locale specific decimal separator leading to unparsable XML Change-Id: Ideae319e41f8a7e34075065c63247d50cdf830c5
* Integrate unknown attributes in the normal UiElementNode workflow.Raphael Moll2011-07-061-15/+15
| | | | | | | | | | Somehow this should have been the default. There's a few cases where this will allow us to simplify the code and that will be for another CL. Also fixes http://code.google.com/p/android/issues/detail?id=17762 Change-Id: Ieccd36f5f4042f414311f09339ed18fc73d7b122
* Sample code to use the layout rendering library.Xavier Ducrohet2011-06-231-1/+6
| | | | | | | | | | | | | | | | | | | 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
* Move tools to 13.Xavier Ducrohet2011-06-211-2/+2
| | | | Change-Id: Ibedcb5627170d107cacf5e9d212f9da11c8d1f3e
* RelativeLayout: Assign ids dynamically, handle multi-drag, bugsTor Norbye2011-06-101-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | This CL fixes three issues with the new relative layout interaction: (1) Assign ids dynamically. Before this changeset you couldn't attach to a node which does not have an @id attribute, since layout params need to name the constraint by id. This changeset changes this such that you can attach to any arbitrary edge, and when you commit the drag, a unique id is generated on the fly and assigned to the node. (2) Handle dragging multiple nodes at the same time. The new constraints code was unconditionally applying the same constraints to all the dragged nodes, which meant they ended up on top of each other. This fixes things such that the first node is assigned the new constraints, and then all subsequent nodes are attached one next to the other, in a direction depending on which edge you attached to (e.g. attaching on the right will arrange the siblings towards the left out from the edge.) (3) Fix a bug in the code to detect and prevent cycles. Change-Id: I157d45e117d3229f285870517b85ed902607b966
* Workaround view info cookie bugTor Norbye2011-06-101-0/+28
| | | | | | | | | This changeset works around the case where a ViewInfo cookie is identical to its parent. This is for example the case for a ZoomControls widget, where the child views have MergeCookies whole value points to the parent ZoomControl. Change-Id: Ie0eb62750fba6eeaa7241edce68e05f853e08a75
* Revert ScreenLayoutSize to ScreenSize.Xavier Ducrohet2011-06-092-6/+6
| | | | | | | | | | | | 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