aboutsummaryrefslogtreecommitdiffstats
path: root/lint/libs/lint_checks/src/com
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2012-08-27 18:08:57 -0700
committerTor Norbye <tnorbye@google.com>2012-08-27 18:10:37 -0700
commit774424394537c69975f8fc0044765db8c252f66f (patch)
tree13ace958f8f6e9d8f7a821af750f4a19920fc1b1 /lint/libs/lint_checks/src/com
parent41cb01a48b44f35adf98f40c116b5e6654b34e16 (diff)
downloadsdk-774424394537c69975f8fc0044765db8c252f66f.zip
sdk-774424394537c69975f8fc0044765db8c252f66f.tar.gz
sdk-774424394537c69975f8fc0044765db8c252f66f.tar.bz2
Fix property sheet value completion
This changeset fixes the value completion such that you can add custom values into properties that also have enum fields. Rather than have separate completion routines for properties based on whether they contain an enum, a flag, a reference, etc., have a single completer which considers all the various formats and combines the results. In addition to combining results, this now also offers completion on dimensions, and offers theme attribute values for references as well. Change-Id: Idbc1799a34b3a3f14ea567654953925bf12afb8f
Diffstat (limited to 'lint/libs/lint_checks/src/com')
-rw-r--r--lint/libs/lint_checks/src/com/android/tools/lint/checks/PxUsageDetector.java14
1 files changed, 8 insertions, 6 deletions
diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/PxUsageDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/PxUsageDetector.java
index 6734592..c7d688f 100644
--- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/PxUsageDetector.java
+++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/PxUsageDetector.java
@@ -17,8 +17,12 @@
package com.android.tools.lint.checks;
import static com.android.tools.lint.detector.api.LintConstants.ATTR_NAME;
+import static com.android.tools.lint.detector.api.LintConstants.ATTR_TEXT_SIZE;
import static com.android.tools.lint.detector.api.LintConstants.TAG_ITEM;
import static com.android.tools.lint.detector.api.LintConstants.TAG_STYLE;
+import static com.android.tools.lint.detector.api.LintConstants.UNIT_DIP;
+import static com.android.tools.lint.detector.api.LintConstants.UNIT_DP;
+import static com.android.tools.lint.detector.api.LintConstants.UNIT_PX;
import com.android.annotations.NonNull;
import com.android.annotations.Nullable;
@@ -42,8 +46,6 @@ import java.util.Collections;
/**
* Check for px dimensions instead of dp dimensions.
* Also look for non-"sp" text sizes.
- * <p>
- * TODO: Look in themes as well (text node usages).
*/
public class PxUsageDetector extends LayoutDetector {
/** The main issue discovered by this detector */
@@ -123,7 +125,7 @@ public class PxUsageDetector extends LayoutDetector {
}
String value = attribute.getValue();
- if (value.endsWith("px") && value.matches("\\d+px")) { //$NON-NLS-1$ //$NON-NLS-2$
+ if (value.endsWith(UNIT_PX) && value.matches("\\d+px")) { //$NON-NLS-1$
if (value.charAt(0) == '0') {
// 0px is fine. 0px is 0dp regardless of density...
return;
@@ -132,8 +134,8 @@ public class PxUsageDetector extends LayoutDetector {
context.report(PX_ISSUE, attribute, context.getLocation(attribute),
"Avoid using \"px\" as units; use \"dp\" instead", null);
}
- } else if ("textSize".equals(attribute.getLocalName())
- && (value.endsWith("dp") || value.endsWith("dip")) //$NON-NLS-1$ //$NON-NLS-2$
+ } else if (ATTR_TEXT_SIZE.equals(attribute.getLocalName())
+ && (value.endsWith(UNIT_DP) || value.endsWith(UNIT_DIP))
&& (value.matches("\\d+di?p"))) {
if (context.isEnabled(DP_ISSUE)) {
context.report(DP_ISSUE, attribute, context.getLocation(attribute),
@@ -185,7 +187,7 @@ public class PxUsageDetector extends LayoutDetector {
|| text.charAt(j - 1) == 'i')) { // ends with dp or di
text = text.trim();
String name = item.getAttribute(ATTR_NAME);
- if ((name.equals("textSize") //$NON-NLS-1$
+ if ((name.equals(ATTR_TEXT_SIZE)
|| name.equals("android:textSize")) //$NON-NLS-1$
&& text.matches("\\d+di?p")) { //$NON-NLS-1$
if (context.isEnabled(DP_ISSUE)) {