aboutsummaryrefslogtreecommitdiffstats
path: root/lint
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2012-10-15 13:03:40 -0700
committerTor Norbye <tnorbye@google.com>2012-10-15 17:46:37 -0700
commita1e7aa7cc973adaba4f31673c897724eb8d9f399 (patch)
treea882deff58ea4fd638421369053660fbc8d21d44 /lint
parent1e6c45d826478a9621f433c28cce38786b890f52 (diff)
downloadsdk-a1e7aa7cc973adaba4f31673c897724eb8d9f399.zip
sdk-a1e7aa7cc973adaba4f31673c897724eb8d9f399.tar.gz
sdk-a1e7aa7cc973adaba4f31673c897724eb8d9f399.tar.bz2
Misc improvements to the multi-configuration editing
* Fix bug in switching to preview configurations * Don't draw drop shadows for thumbnails in Dialog themes * Move the preview title labels to sit above each preview thumbnail * Make error thumbnails include rendering error messages (and wrap if necessary), plus tweak appearance * Make switch animation show rectangles animating in both directions Change-Id: I0995617fa277b48419a88c5203abf5b1d49af711
Diffstat (limited to 'lint')
-rw-r--r--lint/cli/src/com/android/tools/lint/Main.java45
-rw-r--r--lint/libs/lint_checks/tests/src/com/android/tools/lint/MainTest.java46
2 files changed, 3 insertions, 88 deletions
diff --git a/lint/cli/src/com/android/tools/lint/Main.java b/lint/cli/src/com/android/tools/lint/Main.java
index a33890d..ad086c7 100644
--- a/lint/cli/src/com/android/tools/lint/Main.java
+++ b/lint/cli/src/com/android/tools/lint/Main.java
@@ -16,9 +16,9 @@
package com.android.tools.lint;
+import static com.android.SdkConstants.DOT_XML;
import static com.android.tools.lint.client.api.IssueRegistry.LINT_ERROR;
import static com.android.tools.lint.client.api.IssueRegistry.PARSER_ERROR;
-import static com.android.SdkConstants.DOT_XML;
import static com.android.tools.lint.detector.api.LintUtils.endsWith;
import com.android.annotations.NonNull;
@@ -40,6 +40,7 @@ import com.android.tools.lint.detector.api.Location;
import com.android.tools.lint.detector.api.Position;
import com.android.tools.lint.detector.api.Project;
import com.android.tools.lint.detector.api.Severity;
+import com.android.utils.SdkUtils;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.io.Closeables;
@@ -873,47 +874,7 @@ public class Main extends LintClient {
}
static String wrap(String explanation, int lineWidth, String hangingIndent) {
- int explanationLength = explanation.length();
- StringBuilder sb = new StringBuilder(explanationLength * 2);
- int index = 0;
-
- while (index < explanationLength) {
- int lineEnd = explanation.indexOf('\n', index);
- int next;
-
- if (lineEnd != -1 && (lineEnd - index) < lineWidth) {
- next = lineEnd + 1;
- } else {
- // Line is longer than available width; grab as much as we can
- lineEnd = Math.min(index + lineWidth, explanationLength);
- if (lineEnd - index < lineWidth) {
- next = explanationLength;
- } else {
- // then back up to the last space
- int lastSpace = explanation.lastIndexOf(' ', lineEnd);
- if (lastSpace > index) {
- lineEnd = lastSpace;
- next = lastSpace + 1;
- } else {
- // No space anywhere on the line: it contains something wider than
- // can fit (like a long URL) so just hard break it
- next = lineEnd + 1;
- }
- }
- }
-
- if (sb.length() > 0) {
- sb.append(hangingIndent);
- } else {
- lineWidth -= hangingIndent.length();
- }
-
- sb.append(explanation.substring(index, lineEnd));
- sb.append('\n');
- index = next;
- }
-
- return sb.toString();
+ return SdkUtils.wrap(explanation, lineWidth, hangingIndent);
}
private static void printUsage(PrintStream out) {
diff --git a/lint/libs/lint_checks/tests/src/com/android/tools/lint/MainTest.java b/lint/libs/lint_checks/tests/src/com/android/tools/lint/MainTest.java
index 0ea384e..4e7a029 100644
--- a/lint/libs/lint_checks/tests/src/com/android/tools/lint/MainTest.java
+++ b/lint/libs/lint_checks/tests/src/com/android/tools/lint/MainTest.java
@@ -28,52 +28,6 @@ import java.util.List;
@SuppressWarnings("javadoc")
public class MainTest extends AbstractCheckTest {
- public void testWrap() {
- String s =
- "Hardcoding text attributes directly in layout files is bad for several reasons:\n" +
- "\n" +
- "* When creating configuration variations (for example for landscape or portrait)" +
- "you have to repeat the actual text (and keep it up to date when making changes)\n" +
- "\n" +
- "* The application cannot be translated to other languages by just adding new " +
- "translations for existing string resources.";
- String wrapped = Main.wrap(s, 70, "");
- assertEquals(
- "Hardcoding text attributes directly in layout files is bad for several\n" +
- "reasons:\n" +
- "\n" +
- "* When creating configuration variations (for example for landscape or\n" +
- "portrait)you have to repeat the actual text (and keep it up to date\n" +
- "when making changes)\n" +
- "\n" +
- "* The application cannot be translated to other languages by just\n" +
- "adding new translations for existing string resources.\n",
- wrapped);
- }
-
- public void testWrapPrefix() {
- String s =
- "Hardcoding text attributes directly in layout files is bad for several reasons:\n" +
- "\n" +
- "* When creating configuration variations (for example for landscape or portrait)" +
- "you have to repeat the actual text (and keep it up to date when making changes)\n" +
- "\n" +
- "* The application cannot be translated to other languages by just adding new " +
- "translations for existing string resources.";
- String wrapped = Main.wrap(s, 70, " ");
- assertEquals(
- "Hardcoding text attributes directly in layout files is bad for several\n" +
- " reasons:\n" +
- " \n" +
- " * When creating configuration variations (for example for\n" +
- " landscape or portrait)you have to repeat the actual text (and keep\n" +
- " it up to date when making changes)\n" +
- " \n" +
- " * The application cannot be translated to other languages by just\n" +
- " adding new translations for existing string resources.\n",
- wrapped);
- }
-
protected String checkLint(String[] args, List<File> files) throws Exception {
PrintStream previousOut = System.out;
try {