summaryrefslogtreecommitdiff
path: root/core/java/android/text/Layout.java
diff options
context:
space:
mode:
authorMark Wagner <mxw@google.com>2009-10-16 11:44:23 -0700
committerMark Wagner <mxw@google.com>2009-10-16 15:26:31 -0700
commit7b5676e4d40a09ccdbc8b6f691a3d8be23e480d3 (patch)
tree7a5d57d1320df4e46acd77ad329f723487e2a911 /core/java/android/text/Layout.java
parent055e4ea56c42e714dc471d86311f64437f4ed786 (diff)
support for multiline paragraph style indentation
This change is likely incomplete and perhaps not right in other ways. The gist of the change is that the span can return the number of lines to which to apply the "leading margin". Some specific things that should be looked at: 1) if the user has nested multiple LeadingMarginSpans then they will inherit the "line count" feature. This is wrong but I didn't want to spend time fixing it until it was clear that this overall approach was acceptible. 2) The units for how many lines should indented is "lines" rather than something like dips. 3) I wasn't sure what our strategy was for binary compatibility so I didn't want to modify the methods in LeadingMarginSpan. Instead I made another interface with extends LeadingMarginSpan that has the extra method to return the line count.
Diffstat (limited to 'core/java/android/text/Layout.java')
-rw-r--r--core/java/android/text/Layout.java15
1 files changed, 13 insertions, 2 deletions
diff --git a/core/java/android/text/Layout.java b/core/java/android/text/Layout.java
index a92800d011ee..afc686401656 100644
--- a/core/java/android/text/Layout.java
+++ b/core/java/android/text/Layout.java
@@ -294,7 +294,12 @@ public abstract class Layout {
lbaseline, lbottom, buf,
start, end, par, this);
- left += margin.getLeadingMargin(par);
+ boolean useMargin = par;
+ if (margin instanceof LeadingMarginSpan.LeadingMarginSpan2) {
+ int count = ((LeadingMarginSpan.LeadingMarginSpan2)margin).getLeadingMarginLineCount();
+ useMargin = count > i;
+ }
+ left += margin.getLeadingMargin(useMargin);
}
}
}
@@ -1293,7 +1298,13 @@ public abstract class Layout {
LeadingMarginSpan.class);
for (int i = 0; i < spans.length; i++) {
- left += spans[i].getLeadingMargin(par);
+ boolean margin = par;
+ LeadingMarginSpan span = spans[i];
+ if (span instanceof LeadingMarginSpan.LeadingMarginSpan2) {
+ int count = ((LeadingMarginSpan.LeadingMarginSpan2)span).getLeadingMarginLineCount();
+ margin = count >= line;
+ }
+ left += span.getLeadingMargin(margin);
}
}
}