diff options
author | Tor Norbye <tnorbye@google.com> | 2010-11-24 10:07:08 -0800 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2010-11-28 20:35:34 -0800 |
commit | bfcbad18934be1f51ae03d4b6255cfe2d7239aaf (patch) | |
tree | c09dfa51201a4dcca4f048794d4161df75391ec3 /eclipse/plugins/com.android.ide.eclipse.adt/src/com | |
parent | d523d33ce6fb99bac58ccef7650ed59c9564c814 (diff) | |
download | sdk-bfcbad18934be1f51ae03d4b6255cfe2d7239aaf.zip sdk-bfcbad18934be1f51ae03d4b6255cfe2d7239aaf.tar.gz sdk-bfcbad18934be1f51ae03d4b6255cfe2d7239aaf.tar.bz2 |
Extract layout constants into a separate constants class
Combine the constants in BaseView and a LayoutConstants class over in
the internal packages into a new LayoutConstants class, and reference
these constants elsewhere (statically imported). This was suggested by
in the feedback to review #18971.
Change-Id: I40b76f8f6045c34a98f7a2363f96d2942360d1f3
Diffstat (limited to 'eclipse/plugins/com.android.ide.eclipse.adt/src/com')
18 files changed, 150 insertions, 81 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/AbsoluteLayoutRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/AbsoluteLayoutRule.java index 708b67b..348d6cf 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/AbsoluteLayoutRule.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/AbsoluteLayoutRule.java @@ -16,6 +16,8 @@ package com.android.ide.common.layout; +import static com.android.ide.common.layout.LayoutConstants.ANDROID_URI; + import com.android.ide.common.api.DrawingStyle; import com.android.ide.common.api.DropFeedback; import com.android.ide.common.api.IDragElement; diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/BaseLayout.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/BaseLayout.java index 412e495..979a4a2 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/BaseLayout.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/BaseLayout.java @@ -16,17 +16,21 @@ package com.android.ide.common.layout; +import static com.android.ide.common.layout.LayoutConstants.ANDROID_URI; +import static com.android.ide.common.layout.LayoutConstants.ATTR_ID; +import static com.android.ide.common.layout.LayoutConstants.ATTR_TEXT; + import com.android.ide.common.api.DropFeedback; import com.android.ide.common.api.IAttributeInfo; +import com.android.ide.common.api.IAttributeInfo.Format; import com.android.ide.common.api.IClientRulesEngine; import com.android.ide.common.api.IDragElement; +import com.android.ide.common.api.IDragElement.IDragAttribute; import com.android.ide.common.api.IGraphics; import com.android.ide.common.api.INode; import com.android.ide.common.api.MenuAction; import com.android.ide.common.api.Point; import com.android.ide.common.api.Rect; -import com.android.ide.common.api.IAttributeInfo.Format; -import com.android.ide.common.api.IDragElement.IDragAttribute; import java.util.Arrays; import java.util.HashMap; diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/BaseView.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/BaseView.java index 92f0543..4bcf069 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/BaseView.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/BaseView.java @@ -16,6 +16,13 @@ package com.android.ide.common.layout; +import static com.android.ide.common.layout.LayoutConstants.ANDROID_URI; +import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_HEIGHT; +import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_WIDTH; +import static com.android.ide.common.layout.LayoutConstants.VALUE_FILL_PARENT; +import static com.android.ide.common.layout.LayoutConstants.VALUE_MATCH_PARENT; +import static com.android.ide.common.layout.LayoutConstants.VALUE_WRAP_CONTENT; + import com.android.ide.common.api.DropFeedback; import com.android.ide.common.api.IAttributeInfo; import com.android.ide.common.api.IClientRulesEngine; @@ -44,49 +51,6 @@ import java.util.Set; public class BaseView implements IViewRule { protected IClientRulesEngine mRulesEngine; - /** - * Namespace for the Android resource XML, i.e. - * "http://schemas.android.com/apk/res/android" - */ - public static String ANDROID_URI = "http://schemas.android.com/apk/res/android"; //$NON-NLS-1$ - - /** The fully qualified class name of an EditText view */ - public static final String FQCN_EDIT_TEXT = "android.widget.EditText"; //$NON-NLS-1$ - - /** The fully qualified class name of a LinearLayout view */ - public static final String FQCN_LINEAR_LAYOUT = "android.widget.LinearLayout"; //$NON-NLS-1$ - - /** The fully qualified class name of a FrameLayout view */ - public static final String FQCN_FRAME_LAYOUT = "android.widget.FrameLayout"; //$NON-NLS-1$ - - /** The fully qualified class name of a TableRow view */ - public static final String FQCN_TABLE_ROW = "android.widget.TableRow"; //$NON-NLS-1$ - - /** The fully qualified class name of a TabWidget view */ - public static final String FQCN_TAB_WIDGET = "android.widget.TabWidget"; //$NON-NLS-1$ - - // Some common Android layout attribute names used by the view rules. - // All these belong to the attribute namespace ANDROID_URI. - public static final String ATTR_ID = "id"; //$NON-NLS-1$ - - public static final String ATTR_TEXT = "text"; //$NON-NLS-1$ - - public static final String ATTR_LAYOUT_WIDTH = "layout_width"; //$NON-NLS-1$ - - public static final String ATTR_LAYOUT_HEIGHT = "layout_height"; //$NON-NLS-1$ - - public static final String ATTR_SRC = "src"; //$NON-NLS-1$ - - public static final String ATTR_LAYOUT_BELOW = "layout_below"; //$NON-NLS-1$ - - // Some common Android layout attribute values used by the view rules. - public static final String VALUE_FILL_PARENT = "fill_parent"; //$NON-NLS-1$ - - // like fill_parent for API 8 - public static final String VALUE_MATCH_PARENT = "match_parent"; //$NON-NLS-1$ - - public static final String VALUE_WRAP_CONTENT = "wrap_content"; //$NON-NLS-1$ - // Cache of attributes. Key is FQCN of a node mixed with its view hierarchy // parent. Values are a custom map as needed by getContextMenu. private Map<String, Map<String, Prop>> mAttributesMap = diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/DialerFilterRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/DialerFilterRule.java index 54b511e..311af84 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/DialerFilterRule.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/DialerFilterRule.java @@ -16,6 +16,14 @@ package com.android.ide.common.layout; +import static com.android.ide.common.layout.LayoutConstants.ANDROID_URI; +import static com.android.ide.common.layout.LayoutConstants.ATTR_ID; +import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_BELOW; +import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_WIDTH; +import static com.android.ide.common.layout.LayoutConstants.ATTR_TEXT; +import static com.android.ide.common.layout.LayoutConstants.FQCN_EDIT_TEXT; +import static com.android.ide.common.layout.LayoutConstants.VALUE_FILL_PARENT; + import com.android.ide.common.api.INode; import com.android.ide.common.api.IViewRule; import com.android.ide.common.api.InsertType; @@ -32,12 +40,12 @@ public class DialerFilterRule extends BaseView { // A DialerFilter requires a couple of nested EditTexts with fixed ids: if (insertType == InsertType.CREATE) { INode hint = node.appendChild(FQCN_EDIT_TEXT); - hint.setAttribute(ANDROID_URI, BaseView.ATTR_TEXT, "Hint"); + hint.setAttribute(ANDROID_URI, ATTR_TEXT, "Hint"); hint.setAttribute(ANDROID_URI, ATTR_ID, "@android:id/hint"); //$NON-NLS-1$ hint.setAttribute(ANDROID_URI, ATTR_LAYOUT_WIDTH, VALUE_FILL_PARENT); INode primary = node.appendChild(FQCN_EDIT_TEXT); - primary.setAttribute(ANDROID_URI, BaseView.ATTR_TEXT, "Primary"); + primary.setAttribute(ANDROID_URI, ATTR_TEXT, "Primary"); primary.setAttribute(ANDROID_URI, ATTR_ID, "@android:id/primary"); //$NON-NLS-1$ primary.setAttribute(ANDROID_URI, ATTR_LAYOUT_BELOW, "@android:id/hint"); //$NON-NLS-1$ diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/HorizontalScrollViewRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/HorizontalScrollViewRule.java index 547dc04..6ae6872 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/HorizontalScrollViewRule.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/HorizontalScrollViewRule.java @@ -16,6 +16,14 @@ package com.android.ide.common.layout; +import static com.android.ide.common.layout.LayoutConstants.ANDROID_URI; +import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_HEIGHT; +import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_WIDTH; +import static com.android.ide.common.layout.LayoutConstants.ATTR_ORIENTATION; +import static com.android.ide.common.layout.LayoutConstants.FQCN_LINEAR_LAYOUT; +import static com.android.ide.common.layout.LayoutConstants.VALUE_FILL_PARENT; +import static com.android.ide.common.layout.LayoutConstants.VALUE_HORIZONTAL; + import com.android.ide.common.api.INode; import com.android.ide.common.api.IViewRule; import com.android.ide.common.api.InsertType; @@ -42,8 +50,8 @@ public class HorizontalScrollViewRule extends BaseView { // Insert a horizontal linear layout which is commonly used with horizontal scrollbars // as described by the documentation for HorizontalScrollbars. INode linearLayout = node.appendChild(FQCN_LINEAR_LAYOUT); - linearLayout.setAttribute(ANDROID_URI, LinearLayoutRule.ATTR_ORIENTATION, - LinearLayoutRule.VALUE_HORIZONTAL); + linearLayout.setAttribute(ANDROID_URI, ATTR_ORIENTATION, + VALUE_HORIZONTAL); } } diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/ImageButtonRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/ImageButtonRule.java index 7a23f17..9ea5dc2 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/ImageButtonRule.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/ImageButtonRule.java @@ -16,6 +16,9 @@ package com.android.ide.common.layout; +import static com.android.ide.common.layout.LayoutConstants.ANDROID_URI; +import static com.android.ide.common.layout.LayoutConstants.ATTR_SRC; + import com.android.ide.common.api.INode; import com.android.ide.common.api.IViewRule; import com.android.ide.common.api.InsertType; diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/ImageViewRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/ImageViewRule.java index 67cd422..9b1eac3 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/ImageViewRule.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/ImageViewRule.java @@ -16,6 +16,9 @@ package com.android.ide.common.layout; +import static com.android.ide.common.layout.LayoutConstants.ANDROID_URI; +import static com.android.ide.common.layout.LayoutConstants.ATTR_SRC; + import com.android.ide.common.api.INode; import com.android.ide.common.api.IViewRule; import com.android.ide.common.api.InsertType; diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/LayoutConstants.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/LayoutConstants.java index f662411..2a7f5f3 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/LayoutConstants.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/LayoutConstants.java @@ -14,8 +14,7 @@ * limitations under the License. */ -package com.android.ide.eclipse.adt.internal.editors.layout; - +package com.android.ide.common.layout; /** * A bunch of constants that map to either: @@ -26,7 +25,6 @@ package com.android.ide.eclipse.adt.internal.editors.layout; * </ul> */ public class LayoutConstants { - public static final String RELATIVE_LAYOUT = "RelativeLayout"; //$NON-NLS-1$ public static final String LINEAR_LAYOUT = "LinearLayout"; //$NON-NLS-1$ public static final String ABSOLUTE_LAYOUT = "AbsoluteLayout"; //$NON-NLS-1$ @@ -61,6 +59,36 @@ public class LayoutConstants { public static final String VALUE_TRUE = "true"; //$NON-NLS-1$ public static final String VALUE_N_DIP = "%ddip"; //$NON-NLS-1$ - private LayoutConstants() { - } + /** + * Namespace for the Android resource XML, i.e. + * "http://schemas.android.com/apk/res/android" + */ + public static String ANDROID_URI = "http://schemas.android.com/apk/res/android"; //$NON-NLS-1$ + + /** The fully qualified class name of an EditText view */ + public static final String FQCN_EDIT_TEXT = "android.widget.EditText"; //$NON-NLS-1$ + + /** The fully qualified class name of a LinearLayout view */ + public static final String FQCN_LINEAR_LAYOUT = "android.widget.LinearLayout"; //$NON-NLS-1$ + + /** The fully qualified class name of a FrameLayout view */ + public static final String FQCN_FRAME_LAYOUT = "android.widget.FrameLayout"; //$NON-NLS-1$ + + /** The fully qualified class name of a TableRow view */ + public static final String FQCN_TABLE_ROW = "android.widget.TableRow"; //$NON-NLS-1$ + + /** The fully qualified class name of a TabWidget view */ + public static final String FQCN_TAB_WIDGET = "android.widget.TabWidget"; //$NON-NLS-1$ + + public static final String ATTR_SRC = "src"; //$NON-NLS-1$ + + // like fill_parent for API 8 + public static final String VALUE_MATCH_PARENT = "match_parent"; //$NON-NLS-1$ + + public static String ATTR_ORIENTATION = "orientation"; //$NON-NLS-1$ + + public static String VALUE_HORIZONTAL = "horizontal"; //$NON-NLS-1$ + + public static String VALUE_VERTICAL = "vertical"; //$NON-NLS-1$ + } diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/LinearLayoutRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/LinearLayoutRule.java index e31424c..77e6d54 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/LinearLayoutRule.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/LinearLayoutRule.java @@ -16,6 +16,14 @@ package com.android.ide.common.layout; +import static com.android.ide.common.layout.LayoutConstants.ANDROID_URI; +import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_HEIGHT; +import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_WIDTH; +import static com.android.ide.common.layout.LayoutConstants.ATTR_ORIENTATION; +import static com.android.ide.common.layout.LayoutConstants.VALUE_FILL_PARENT; +import static com.android.ide.common.layout.LayoutConstants.VALUE_HORIZONTAL; +import static com.android.ide.common.layout.LayoutConstants.VALUE_VERTICAL; + import com.android.ide.common.api.DrawingStyle; import com.android.ide.common.api.DropFeedback; import com.android.ide.common.api.IDragElement; @@ -25,12 +33,12 @@ import com.android.ide.common.api.IMenuCallback; import com.android.ide.common.api.INode; import com.android.ide.common.api.INodeHandler; import com.android.ide.common.api.IViewMetadata; +import com.android.ide.common.api.IViewMetadata.FillPreference; import com.android.ide.common.api.IViewRule; import com.android.ide.common.api.InsertType; import com.android.ide.common.api.MenuAction; import com.android.ide.common.api.Point; import com.android.ide.common.api.Rect; -import com.android.ide.common.api.IViewMetadata.FillPreference; import java.util.ArrayList; import java.util.List; @@ -41,10 +49,6 @@ import java.util.Map; * classes. */ public class LinearLayoutRule extends BaseLayout { - public static String ATTR_ORIENTATION = "orientation"; //$NON-NLS-1$ - public static String VALUE_HORIZONTAL = "horizontal"; //$NON-NLS-1$ - public static String VALUE_VERTICAL = "vertical"; //$NON-NLS-1$ - /** * Add an explicit Orientation toggle to the context menu. */ diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/ListViewRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/ListViewRule.java index 347057a..d3d226c 100755 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/ListViewRule.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/ListViewRule.java @@ -16,6 +16,10 @@ package com.android.ide.common.layout; +import static com.android.ide.common.layout.LayoutConstants.ANDROID_URI; +import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_WIDTH; +import static com.android.ide.common.layout.LayoutConstants.VALUE_FILL_PARENT; + import com.android.ide.common.api.INode; import com.android.ide.common.api.IViewRule; import com.android.ide.common.api.InsertType; diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/MapViewRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/MapViewRule.java index 2eff369..b8ddedd 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/MapViewRule.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/MapViewRule.java @@ -16,6 +16,8 @@ package com.android.ide.common.layout; +import static com.android.ide.common.layout.LayoutConstants.ANDROID_URI; + import com.android.ide.common.api.INode; import com.android.ide.common.api.IViewRule; import com.android.ide.common.api.InsertType; diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/RelativeLayoutRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/RelativeLayoutRule.java index 96e6aa6..04629b2 100755 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/RelativeLayoutRule.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/RelativeLayoutRule.java @@ -16,19 +16,22 @@ package com.android.ide.common.layout; +import static com.android.ide.common.layout.LayoutConstants.ANDROID_URI; +import static com.android.ide.common.layout.LayoutConstants.ATTR_ID; + import com.android.ide.common.api.DrawingStyle; import com.android.ide.common.api.DropFeedback; import com.android.ide.common.api.IAttributeInfo; +import com.android.ide.common.api.IAttributeInfo.Format; import com.android.ide.common.api.IDragElement; import com.android.ide.common.api.IFeedbackPainter; import com.android.ide.common.api.IGraphics; import com.android.ide.common.api.INode; +import com.android.ide.common.api.INode.IAttribute; import com.android.ide.common.api.INodeHandler; import com.android.ide.common.api.IViewRule; import com.android.ide.common.api.Point; import com.android.ide.common.api.Rect; -import com.android.ide.common.api.IAttributeInfo.Format; -import com.android.ide.common.api.INode.IAttribute; import java.util.ArrayList; import java.util.Collections; diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/ScrollViewRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/ScrollViewRule.java index 5ce8bad..5324278 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/ScrollViewRule.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/ScrollViewRule.java @@ -16,6 +16,12 @@ package com.android.ide.common.layout; +import static com.android.ide.common.layout.LayoutConstants.ANDROID_URI; +import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_HEIGHT; +import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_WIDTH; +import static com.android.ide.common.layout.LayoutConstants.FQCN_LINEAR_LAYOUT; +import static com.android.ide.common.layout.LayoutConstants.VALUE_FILL_PARENT; + import com.android.ide.common.api.INode; import com.android.ide.common.api.IViewRule; import com.android.ide.common.api.InsertType; diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/SeekBarRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/SeekBarRule.java index b6d184f..727d231 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/SeekBarRule.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/SeekBarRule.java @@ -16,6 +16,10 @@ package com.android.ide.common.layout; +import static com.android.ide.common.layout.LayoutConstants.ANDROID_URI; +import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_WIDTH; +import static com.android.ide.common.layout.LayoutConstants.VALUE_FILL_PARENT; + import com.android.ide.common.api.INode; import com.android.ide.common.api.IViewRule; import com.android.ide.common.api.InsertType; diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/TabHostRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/TabHostRule.java index f47da68..dc512bd 100755 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/TabHostRule.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/TabHostRule.java @@ -16,6 +16,18 @@ package com.android.ide.common.layout; +import static com.android.ide.common.layout.LayoutConstants.ANDROID_URI; +import static com.android.ide.common.layout.LayoutConstants.ATTR_ID; +import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_HEIGHT; +import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_WIDTH; +import static com.android.ide.common.layout.LayoutConstants.ATTR_ORIENTATION; +import static com.android.ide.common.layout.LayoutConstants.FQCN_FRAME_LAYOUT; +import static com.android.ide.common.layout.LayoutConstants.FQCN_LINEAR_LAYOUT; +import static com.android.ide.common.layout.LayoutConstants.FQCN_TAB_WIDGET; +import static com.android.ide.common.layout.LayoutConstants.VALUE_FILL_PARENT; +import static com.android.ide.common.layout.LayoutConstants.VALUE_VERTICAL; +import static com.android.ide.common.layout.LayoutConstants.VALUE_WRAP_CONTENT; + import com.android.ide.common.api.INode; import com.android.ide.common.api.IViewRule; import com.android.ide.common.api.InsertType; @@ -41,8 +53,8 @@ public class TabHostRule extends IgnoredLayoutRule { INode linear = node.appendChild(FQCN_LINEAR_LAYOUT); linear.setAttribute(ANDROID_URI, ATTR_LAYOUT_WIDTH, VALUE_FILL_PARENT); linear.setAttribute(ANDROID_URI, ATTR_LAYOUT_HEIGHT, VALUE_FILL_PARENT); - linear.setAttribute(ANDROID_URI, LinearLayoutRule.ATTR_ORIENTATION, - LinearLayoutRule.VALUE_VERTICAL); + linear.setAttribute(ANDROID_URI, ATTR_ORIENTATION, + VALUE_VERTICAL); INode tab = linear.appendChild(FQCN_TAB_WIDGET); tab.setAttribute(ANDROID_URI, ATTR_LAYOUT_WIDTH, VALUE_FILL_PARENT); diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/TableLayoutRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/TableLayoutRule.java index a5d772c..6ac670f 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/TableLayoutRule.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/TableLayoutRule.java @@ -15,6 +15,8 @@ */ package com.android.ide.common.layout; +import static com.android.ide.common.layout.LayoutConstants.FQCN_TABLE_ROW; + import com.android.ide.common.api.IMenuCallback; import com.android.ide.common.api.INode; import com.android.ide.common.api.IViewRule; diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/descriptors/DescriptorsUtils.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/descriptors/DescriptorsUtils.java index 0e1e8bd..09691b8 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/descriptors/DescriptorsUtils.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/descriptors/DescriptorsUtils.java @@ -16,10 +16,18 @@ package com.android.ide.eclipse.adt.internal.editors.descriptors; +import static com.android.ide.common.layout.LayoutConstants.ATTR_ID; +import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_BELOW; +import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_HEIGHT; +import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_WIDTH; +import static com.android.ide.common.layout.LayoutConstants.ATTR_TEXT; +import static com.android.ide.common.layout.LayoutConstants.RELATIVE_LAYOUT; +import static com.android.ide.common.layout.LayoutConstants.VALUE_FILL_PARENT; +import static com.android.ide.common.layout.LayoutConstants.VALUE_WRAP_CONTENT; + import com.android.ide.common.api.IAttributeInfo.Format; import com.android.ide.common.resources.platform.AttributeInfo; import com.android.ide.eclipse.adt.AndroidConstants; -import com.android.ide.eclipse.adt.internal.editors.layout.LayoutConstants; import com.android.ide.eclipse.adt.internal.editors.uimodel.UiDocumentNode; import com.android.ide.eclipse.adt.internal.editors.uimodel.UiElementNode; import com.android.ide.eclipse.adt.internal.resources.ResourceType; @@ -30,8 +38,8 @@ import org.eclipse.swt.graphics.Image; import java.util.ArrayList; import java.util.HashSet; import java.util.Map; -import java.util.Set; import java.util.Map.Entry; +import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -668,27 +676,27 @@ public final class DescriptorsUtils { boolean fill = ui_node.getDescriptor().hasChildren() && ui_node.getUiParent() instanceof UiDocumentNode; ui_node.setAttributeValue( - LayoutConstants.ATTR_LAYOUT_WIDTH, + ATTR_LAYOUT_WIDTH, SdkConstants.NS_RESOURCES, - fill ? LayoutConstants.VALUE_FILL_PARENT : LayoutConstants.VALUE_WRAP_CONTENT, + fill ? VALUE_FILL_PARENT : VALUE_WRAP_CONTENT, false /* override */); ui_node.setAttributeValue( - LayoutConstants.ATTR_LAYOUT_HEIGHT, + ATTR_LAYOUT_HEIGHT, SdkConstants.NS_RESOURCES, - fill ? LayoutConstants.VALUE_FILL_PARENT : LayoutConstants.VALUE_WRAP_CONTENT, + fill ? VALUE_FILL_PARENT : VALUE_WRAP_CONTENT, false /* override */); String widget_id = getFreeWidgetId(ui_node); if (widget_id != null) { ui_node.setAttributeValue( - LayoutConstants.ATTR_ID, + ATTR_ID, SdkConstants.NS_RESOURCES, widget_id, false /* override */); } ui_node.setAttributeValue( - LayoutConstants.ATTR_TEXT, + ATTR_TEXT, SdkConstants.NS_RESOURCES, widget_id, false /*override*/); @@ -697,14 +705,14 @@ public final class DescriptorsUtils { UiElementNode ui_parent = ui_node.getUiParent(); if (ui_parent != null && ui_parent.getDescriptor().getXmlLocalName().equals( - LayoutConstants.RELATIVE_LAYOUT)) { + RELATIVE_LAYOUT)) { UiElementNode ui_previous = ui_node.getUiPreviousSibling(); if (ui_previous != null) { - String id = ui_previous.getAttributeValue(LayoutConstants.ATTR_ID); + String id = ui_previous.getAttributeValue(ATTR_ID); if (id != null && id.length() > 0) { id = id.replace("@+", "@"); //$NON-NLS-1$ //$NON-NLS-2$ ui_node.setAttributeValue( - LayoutConstants.ATTR_LAYOUT_BELOW, + ATTR_LAYOUT_BELOW, SdkConstants.NS_RESOURCES, id, false /* override */); @@ -804,7 +812,7 @@ public final class DescriptorsUtils { params[2] = generated; } - String id = uiRoot.getAttributeValue(LayoutConstants.ATTR_ID); + String id = uiRoot.getAttributeValue(ATTR_ID); if (id != null) { id = id.replace("@+id/", ""); //$NON-NLS-1$ $NON-NLS-2$ id = id.replace("@id/", ""); //$NON-NLS-1$ $NON-NLS-2$ diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/PaletteComposite.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/PaletteComposite.java index 142d8eb..ba7b7b5 100755 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/PaletteComposite.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/PaletteComposite.java @@ -16,15 +16,19 @@ package com.android.ide.eclipse.adt.internal.editors.layout.gle2; +import static com.android.ide.common.layout.LayoutConstants.ANDROID_URI; +import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_HEIGHT; +import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_WIDTH; +import static com.android.ide.common.layout.LayoutConstants.ATTR_TEXT; +import static com.android.ide.common.layout.LayoutConstants.VALUE_WRAP_CONTENT; + import com.android.ide.common.api.InsertType; import com.android.ide.common.api.Rect; -import com.android.ide.common.layout.BaseView; import com.android.ide.common.layoutlib.LayoutLibrary; import com.android.ide.eclipse.adt.internal.editors.descriptors.DescriptorsUtils; import com.android.ide.eclipse.adt.internal.editors.descriptors.DocumentDescriptor; import com.android.ide.eclipse.adt.internal.editors.descriptors.ElementDescriptor; import com.android.ide.eclipse.adt.internal.editors.descriptors.XmlnsAttributeDescriptor; -import com.android.ide.eclipse.adt.internal.editors.layout.LayoutConstants; import com.android.ide.eclipse.adt.internal.editors.layout.LayoutEditor; import com.android.ide.eclipse.adt.internal.editors.layout.descriptors.LayoutDescriptors; import com.android.ide.eclipse.adt.internal.editors.layout.gre.NodeFactory; @@ -676,19 +680,19 @@ public class PaletteComposite extends Composite { // Set up a proper name space Attr attr = document.createAttributeNS(XmlnsAttributeDescriptor.XMLNS_URI, "xmlns:android"); //$NON-NLS-1$ - attr.setValue(BaseView.ANDROID_URI); + attr.setValue(ANDROID_URI); element.getAttributes().setNamedItemNS(attr); element.setAttributeNS(SdkConstants.NS_RESOURCES, - LayoutConstants.ATTR_LAYOUT_WIDTH, LayoutConstants.VALUE_WRAP_CONTENT); + ATTR_LAYOUT_WIDTH, VALUE_WRAP_CONTENT); element.setAttributeNS(SdkConstants.NS_RESOURCES, - LayoutConstants.ATTR_LAYOUT_HEIGHT, LayoutConstants.VALUE_WRAP_CONTENT); + ATTR_LAYOUT_HEIGHT, VALUE_WRAP_CONTENT); // This doesn't apply to all, but doesn't seem to cause harm and makes for a // better experience with text-oriented views like buttons and texts UiElementNode uiRoot = layoutEditor.getUiRootNode(); String text = DescriptorsUtils.getFreeWidgetId(uiRoot, viewName); - element.setAttributeNS(SdkConstants.NS_RESOURCES, LayoutConstants.ATTR_TEXT, text); + element.setAttributeNS(SdkConstants.NS_RESOURCES, ATTR_TEXT, text); document.appendChild(element); |