OSDN Git Service

Add new rules to layoutopt: UseCompoundDrawables and UselessLayout.
[android-x86/development.git] / tools / layoutopt / libs / uix / src / resources / rules / UselessLayout.rule
1 // Rule: UselessLayout
2 //
3 // Description: Checks whether current node can be removed.
4 //
5 // Conditions:
6 // - The node has children
7 // - The node does not have siblings
8 // - The node does not have a background or its parent does not have a
9 //   background or neither the node and its parent have a background
10 // - The parent is not a <merge/>
11
12 if (!xml.isRoot() && xml['..'].name() != "merge" && xml['..']['*'].size() == 1 &&
13         xml['*'].size() > 0 && ((xml.'@android:background' || xml['..'].'@android:background') ||
14         (!xml.'@android:background' && !xml['..'].'@android:background'))) {
15     analysis << [node: node, description: "This ${xml.name()} layout or " +
16             "its ${xml['..'].name()} parent is " +
17             "${xml['..'].'@android:id' ? "possibly useless" : "useless"}"]
18 }