diff options
author | Tor Norbye <tnorbye@google.com> | 2011-08-15 16:38:30 -0700 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2011-08-19 16:43:08 -0700 |
commit | e287bc8580e19d72a911615475b353790cf000eb (patch) | |
tree | b9fa61fcb0b68f29fdd56359b84bb37aa815c4ab /rule_api/src | |
parent | 39f953c53d4388044afdac63629e260b0a1ddce5 (diff) | |
download | sdk-e287bc8580e19d72a911615475b353790cf000eb.zip sdk-e287bc8580e19d72a911615475b353790cf000eb.tar.gz sdk-e287bc8580e19d72a911615475b353790cf000eb.tar.bz2 |
Layout editor property menu improvements
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
Diffstat (limited to 'rule_api/src')
3 files changed, 30 insertions, 2 deletions
diff --git a/rule_api/src/com/android/ide/common/api/IAttributeInfo.java b/rule_api/src/com/android/ide/common/api/IAttributeInfo.java index 2a6ecd8..da1bc9e 100755 --- a/rule_api/src/com/android/ide/common/api/IAttributeInfo.java +++ b/rule_api/src/com/android/ide/common/api/IAttributeInfo.java @@ -81,4 +81,6 @@ public interface IAttributeInfo { /** Returns the documentation for deprecated attributes. Null if not deprecated. */ public String getDeprecatedDoc(); + /** Returns the fully qualified class name of the view defining this attribute */ + public String getDefinedBy(); } diff --git a/rule_api/src/com/android/ide/common/api/INode.java b/rule_api/src/com/android/ide/common/api/INode.java index e3f34a9..b4cb638 100755 --- a/rule_api/src/com/android/ide/common/api/INode.java +++ b/rule_api/src/com/android/ide/common/api/INode.java @@ -19,6 +19,8 @@ package com.android.ide.common.api; import com.android.ide.common.api.IDragElement.IDragAttribute; +import java.util.List; + /** * Represents a view in the XML layout being edited. @@ -217,11 +219,25 @@ public interface INode { * If you want attributes actually written in the XML and their values, please use * {@link #getStringAttr(String, String)} or {@link #getLiveAttributes()} instead. * - * @return A non-null possible-empty list of {@link IAttributeInfo}. + * @return A non-null possibly-empty list of {@link IAttributeInfo}. */ public IAttributeInfo[] getDeclaredAttributes(); /** + * Returns the list of classes (fully qualified class names) that are + * contributing properties to the {@link #getDeclaredAttributes()} attribute + * list, in order from most specific to least specific (in other words, + * android.view.View will be last in the list.) This is usually the same as + * the super class chain of a view, but it skips any views that do not + * contribute attributes. + * + * @return a list of views classes that contribute attributes to this node, + * which is never null because at least android.view.View will + * contribute attributes. + */ + public List<String> getAttributeSources(); + + /** * Returns the list of all attributes defined in the XML for this node. * <p/> * This looks up an attribute in the <em>current</em> XML source, not the in-memory model. @@ -232,7 +248,7 @@ public interface INode { * If you want a list of all possible attributes, whether used in the XML or not by * this node, please see {@link #getDeclaredAttributes()} instead. * - * @return A non-null possible-empty list of {@link IAttribute}. + * @return A non-null possibly-empty list of {@link IAttribute}. */ public IAttribute[] getLiveAttributes(); diff --git a/rule_api/src/com/android/ide/common/api/IViewMetadata.java b/rule_api/src/com/android/ide/common/api/IViewMetadata.java index 0687f30..8646764 100644 --- a/rule_api/src/com/android/ide/common/api/IViewMetadata.java +++ b/rule_api/src/com/android/ide/common/api/IViewMetadata.java @@ -16,6 +16,8 @@ package com.android.ide.common.api; +import java.util.List; + /** * Metadata about a particular view. The metadata for a View can be found by asking the * {@link IClientRulesEngine} for the metadata for a given class via @@ -49,6 +51,14 @@ public interface IViewMetadata { public FillPreference getFillPreference(); /** + * Returns the most common attributes for this view. + * + * @return a list of attribute names (not including a namespace prefix) that + * are commonly set for this type of view, never null + */ + public List<String> getTopAttributes(); + + /** * Types of fill behavior that views can prefer. * <p> * TODO: Consider better names. FillPolicy? Stretchiness? |