This change also refactors the uix library to remove an unnecessary class (LayoutNode.) The refactoring helps writing cleaner script by accessing only the node object instead of xml and node. This change also augment the capabilities of the node in Groovy scripts. Change-Id: Id7515f9a79826909834d82496a6d9dfbc19988ad
17 lines
690 B
Plaintext
17 lines
690 B
Plaintext
// Rule: MergeRootFrameLayout
|
|
//
|
|
// Description: Checks whether the root node of the XML document can be
|
|
// replaced with a <merge /> tag.
|
|
//
|
|
// Conditions:
|
|
// - The node is the root of the document
|
|
// - The node is a FrameLayout
|
|
// - The node is fill_parent in both orientation *or* it has no layout_gravity
|
|
// - The node does not have a background nor a foreground
|
|
|
|
if (node.isRoot() && node.is("FrameLayout") && !node.'@android:background' &&
|
|
!node.'@android:foreground' && ((node.isWidthFillParent() &&
|
|
node.isHeightFillParent()) || !node.'@android:layout_gravity')) {
|
|
analysis << "The root-level <FrameLayout/> can be replaced with <merge/>"
|
|
}
|