superClasses[2] = paramsClassName;
}
HashMap<String, ArrayList<IClassDescriptor>> found =
- mClassLoader.findClassesDerivingFrom("android.", superClasses);
+ mClassLoader.findClassesDerivingFrom("android.", superClasses); //$NON-NLS-1$
mTopViewClass = mClassLoader.getClass(rootClassName);
mTopGroupClass = mClassLoader.getClass(groupClassName);
if (paramsClassName != null) {
addView(mTopViewClass);
// ViewGroup derives from View
- mGroupMap.get(groupClassName).setSuperClass(
- mViewMap.get(rootClassName));
+ mGroupMap.get(groupClassName).setSuperClass(mViewMap.get(rootClassName));
progress.setWorkRemaining(mGroupList.size() + mViewList.size());
private IClassDescriptor findLayoutParams(IClassDescriptor groupClass) {
IClassDescriptor[] innerClasses = groupClass.getDeclaredClasses();
for (IClassDescriptor innerClass : innerClasses) {
- if (innerClass.getSimpleName().equals(AndroidConstants.CLASS_LAYOUTPARAMS)) {
+ if (innerClass.getSimpleName().equals(AndroidConstants.CLASS_NAME_LAYOUTPARAMS)) {
return innerClass;
}
}
public final static String CLASS_CONTEXT = "android.content.Context"; //$NON-NLS-1$
public final static String CLASS_VIEW = "android.view.View"; //$NON-NLS-1$
public final static String CLASS_VIEWGROUP = "android.view.ViewGroup"; //$NON-NLS-1$
- public final static String CLASS_LAYOUTPARAMS = "LayoutParams"; //$NON-NLS-1$
+ public final static String CLASS_NAME_LAYOUTPARAMS = "LayoutParams"; //$NON-NLS-1$
public final static String CLASS_VIEWGROUP_LAYOUTPARAMS =
- CLASS_VIEWGROUP + "$" + CLASS_LAYOUTPARAMS; //$NON-NLS-1$
- public final static String CLASS_FRAMELAYOUT = "FrameLayout"; //$NON-NLS-1$
+ CLASS_VIEWGROUP + "$" + CLASS_NAME_LAYOUTPARAMS; //$NON-NLS-1$
+ public final static String CLASS_NAME_FRAMELAYOUT = "FrameLayout"; //$NON-NLS-1$
+ public final static String CLASS_FRAMELAYOUT =
+ "android.widget." + CLASS_NAME_FRAMELAYOUT; //$NON-NLS-1$
public final static String CLASS_PREFERENCE = "android.preference.Preference"; //$NON-NLS-1$
- public final static String CLASS_PREFERENCE_SCREEN = "PreferenceScreen"; //$NON-NLS-1$
+ public final static String CLASS_NAME_PREFERENCE_SCREEN = "PreferenceScreen"; //$NON-NLS-1$
public final static String CLASS_PREFERENCES =
- "android.preference." + CLASS_PREFERENCE_SCREEN; //$NON-NLS-1$
+ "android.preference." + CLASS_NAME_PREFERENCE_SCREEN; //$NON-NLS-1$
public final static String CLASS_PREFERENCEGROUP = "android.preference.PreferenceGroup"; //$NON-NLS-1$
public final static String CLASS_PARCELABLE = "android.os.Parcelable"; //$NON-NLS-1$
// The <merge> tag can only be a root tag, so it is added at the end.
// It gets everything else as children but it is not made a child itself.
- ElementDescriptor mergeTag = createMerge();
+ ElementDescriptor mergeTag = createMerge(newLayouts);
mergeTag.setChildren(newDescriptors); // mergeTag makes a copy of the list
newDescriptors.add(mergeTag);
newLayouts.add(mergeTag);
if (need_separator) {
String title;
if (layoutParams.getShortClassName().equals(
- AndroidConstants.CLASS_LAYOUTPARAMS)) {
+ AndroidConstants.CLASS_NAME_LAYOUTPARAMS)) {
title = String.format("Layout Attributes from %1$s",
layoutParams.getViewLayoutClass().getShortClassName());
} else {
/**
* Creates a new <include> descriptor and adds it to the list of view descriptors.
*
- * @param newViews A list of view descriptors being populated. Also used to find the
- * View description and extract its layout attributes.
+ * @param knownViews A list of view descriptors being populated. Also used to find the
+ * View descriptor and extract its layout attributes.
*/
- private void insertInclude(ArrayList<ElementDescriptor> newViews) {
+ private void insertInclude(ArrayList<ElementDescriptor> knownViews) {
String xml_name = "include"; //$NON-NLS-1$
// Create the include custom attributes
null); //overrides
// Find View and inherit all its layout attributes
- AttributeDescriptor[] viewLayoutAttribs = findViewLayoutAttributes(newViews);
+ AttributeDescriptor[] viewLayoutAttribs = findViewLayoutAttributes(
+ AndroidConstants.CLASS_VIEW, knownViews);
// Create the include descriptor
ViewElementDescriptor desc = new ViewElementDescriptor(xml_name, // xml_name
null, // children
false /* mandatory */);
- newViews.add(desc);
- }
-
- /**
- * Finds the View descriptor and retrieves all its layout attributes.
- */
- private AttributeDescriptor[] findViewLayoutAttributes(
- ArrayList<ElementDescriptor> newViews) {
-
- for (ElementDescriptor desc : newViews) {
- if (desc instanceof ViewElementDescriptor) {
- ViewElementDescriptor viewDesc = (ViewElementDescriptor) desc;
- if (AndroidConstants.CLASS_VIEW.equals(viewDesc.getCanonicalClassName())) {
- return viewDesc.getLayoutAttributes();
- }
- }
- }
-
- return null;
+ knownViews.add(desc);
}
/**
* Creates and return a new <merge> descriptor.
+ * @param knownLayouts A list of all known layout view descriptors, used to find the
+ * FrameLayout descriptor and extract its layout attributes.
*/
- private ElementDescriptor createMerge() {
+ private ElementDescriptor createMerge(ArrayList<ElementDescriptor> knownLayouts) {
String xml_name = "merge"; //$NON-NLS-1$
+ // Find View and inherit all its layout attributes
+ AttributeDescriptor[] viewLayoutAttribs = findViewLayoutAttributes(
+ AndroidConstants.CLASS_FRAMELAYOUT, knownLayouts);
+
// Create the include descriptor
ViewElementDescriptor desc = new ViewElementDescriptor(xml_name, // xml_name
xml_name, // ui_name
"A root tag useful for XML layouts inflated using a ViewStub.", // tooltip
null, // sdk_url
null, // attributes
- null, // layout attributes
+ viewLayoutAttribs, // layout attributes
null, // children
false /* mandatory */);
return desc;
}
+
+ /**
+ * Finds the descriptor and retrieves all its layout attributes.
+ */
+ private AttributeDescriptor[] findViewLayoutAttributes(
+ String viewFqcn,
+ ArrayList<ElementDescriptor> knownViews) {
+
+ for (ElementDescriptor desc : knownViews) {
+ if (desc instanceof ViewElementDescriptor) {
+ ViewElementDescriptor viewDesc = (ViewElementDescriptor) desc;
+ if (viewFqcn.equals(viewDesc.getCanonicalClassName())) {
+ return viewDesc.getLayoutAttributes();
+ }
+ }
+ }
+
+ return null;
+ }
}