OSDN Git Service

More lint checks: translation, i18n, proguard, gridlayout, "px"
authorTor Norbye <tnorbye@google.com>
Tue, 18 Oct 2011 01:32:51 +0000 (18:32 -0700)
committerTor Norbye <tnorbye@google.com>
Thu, 20 Oct 2011 23:35:49 +0000 (16:35 -0700)
commit8027fad9680e1622d7c70be330422d6b11fc6c88
tree21c78e65820234b8dc3638d3624450997fa7cd91
parenta85107f7d763276a5a040cf68e2046ac54202015
More lint checks: translation, i18n, proguard, gridlayout, "px"

This changeset adds more lint checks:

(1) Translation. It looks at all the string values in the application,
    and if there are discrepancies (where a translatable string is not
    defined in all provided languages and regions) then these are
    listed.

(2) Internationalization. It looks for text: and contentDescription:
    attributes and ensures that these refer to @string resources, not
    hardcoded string values. This lint warning also has an associated
    quickfix when shown in Eclipse which invokes the Extract String
    refactoring wizard on the right selection context.

(3) Proguard. It looks for the old (broken) patterns we had in older
    proguard.cfg files (-keepclasseswithmembernames instead of
    -keepclasseswithmembers which implies shrinking.)

(4) GridLayout. It looks at the layout constraints provided on views
    in a GridLayout and ensures that they fall within the overall
    dimensions of the grid.

(5) "px" usage. It looks for dimensions using "px" as a unit and
    recommends switching to dp instead. This lint warning also has a
    quickfix in Eclipse which pops up a dialog asking for the screen
    density and then converts the px value to the right dp value and
    changes the unit.

(6) TextFields. It looks at EditTexts and makes sure they either set
    inputType, hint or inputMethod. There's a quickfix in Eclipse for
    setting the inputType, which adds the property and automatically
    invokes content assist for showing the possible values.

This changeset also adds some quick fixes for a few existing lint
warnings:

(7) Accessibility: Insert a content description attribute, front the
    editor and select the placeholder value.

(8) Useless leaf layout: Remove the leaf layout

(9) Useless middle layout: Invoke the Remove Container visual
    refactoring

10) Inefficient Linear Layout Weights: Change the attribute to 0dp

Plus unit tests.

Change-Id: Iebd7b23224a898bd1851abd578460019aee44df5
45 files changed:
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/LayoutConstants.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/AndroidXmlEditor.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/UnwrapRefactoring.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/LintFix.java [new file with mode: 0644]
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/LintFixGenerator.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/LintListDialog.java
lint/cli/src/com/android/tools/lint/Main.java
lint/libs/lint_api/src/com/android/tools/lint/api/Lint.java
lint/libs/lint_api/src/com/android/tools/lint/api/XmlVisitor.java
lint/libs/lint_api/src/com/android/tools/lint/detector/api/Issue.java
lint/libs/lint_api/src/com/android/tools/lint/detector/api/LayoutDetector.java
lint/libs/lint_checks/src/com/android/tools/lint/checks/AccessibilityDetector.java
lint/libs/lint_checks/src/com/android/tools/lint/checks/BuiltinDetectorRegistry.java
lint/libs/lint_checks/src/com/android/tools/lint/checks/ChildCountDetector.java
lint/libs/lint_checks/src/com/android/tools/lint/checks/DuplicateIdDetector.java
lint/libs/lint_checks/src/com/android/tools/lint/checks/GridLayoutDetector.java [new file with mode: 0644]
lint/libs/lint_checks/src/com/android/tools/lint/checks/HardcodedValuesDetector.java [new file with mode: 0644]
lint/libs/lint_checks/src/com/android/tools/lint/checks/InefficientWeightDetector.java
lint/libs/lint_checks/src/com/android/tools/lint/checks/MergeRootFrameLayoutDetector.java
lint/libs/lint_checks/src/com/android/tools/lint/checks/NestedScrollingWidgetDetector.java
lint/libs/lint_checks/src/com/android/tools/lint/checks/ProguardDetector.java [new file with mode: 0644]
lint/libs/lint_checks/src/com/android/tools/lint/checks/PxUsageDetector.java [new file with mode: 0644]
lint/libs/lint_checks/src/com/android/tools/lint/checks/ScrollViewChildDetector.java
lint/libs/lint_checks/src/com/android/tools/lint/checks/StateListDetector.java
lint/libs/lint_checks/src/com/android/tools/lint/checks/TextFieldDetector.java [new file with mode: 0644]
lint/libs/lint_checks/src/com/android/tools/lint/checks/TooManyViewsDetector.java
lint/libs/lint_checks/src/com/android/tools/lint/checks/TranslationDetector.java [new file with mode: 0644]
lint/libs/lint_checks/src/com/android/tools/lint/checks/UseCompoundDrawableDetector.java
lint/libs/lint_checks/src/com/android/tools/lint/checks/UselessViewDetector.java
lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/GridLayoutDetectorTest.java [new file with mode: 0644]
lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/HardcodedValuesDetectorTest.java [new file with mode: 0644]
lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/ProguardDetectorTest.java [new file with mode: 0644]
lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/PxUsageDetectorTest.java [new file with mode: 0644]
lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/TextFieldDetectorTest.java [new file with mode: 0644]
lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/TranslationDetectorTest.java [new file with mode: 0644]
lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/data/layout/gridlayout.xml [new file with mode: 0644]
lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/data/layout/note_edit.xml [new file with mode: 0644]
lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/data/layout/now_playing_after.xml [new file with mode: 0644]
lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/data/proguard.cfg [new file with mode: 0644]
lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/data/values-cs/strings.xml [new file with mode: 0644]
lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/data/values-de-rDE/strings.xml [new file with mode: 0644]
lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/data/values-es-rUS/strings.xml [new file with mode: 0644]
lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/data/values-land/strings.xml [new file with mode: 0644]
lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/data/values-nl-rNL/strings.xml [new file with mode: 0644]
lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/data/values/strings.xml [new file with mode: 0644]