diff options
author | Mark Wagner <mxw@google.com> | 2009-10-19 14:04:00 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2009-10-19 14:04:00 -0700 |
commit | da4204caa487bc613e51684db457ef4be6a914fc (patch) | |
tree | 70c7ba833da081bd090528d8e8d21af9b9dd60c2 /core | |
parent | 5b231096f25dcca09e17e485684f1f55f8fc67a4 (diff) | |
parent | dad4780bbd6be0891ea8745bd274fc8d6882f071 (diff) | |
download | frameworks_base-da4204caa487bc613e51684db457ef4be6a914fc.zip frameworks_base-da4204caa487bc613e51684db457ef4be6a914fc.tar.gz frameworks_base-da4204caa487bc613e51684db457ef4be6a914fc.tar.bz2 |
am dad4780b: Merge change I3834b1cb into eclair-mr2
Merge commit 'dad4780bbd6be0891ea8745bd274fc8d6882f071' into eclair-mr2-plus-aosp
* commit 'dad4780bbd6be0891ea8745bd274fc8d6882f071':
support for multiline paragraph style indentation
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/text/Layout.java | 15 | ||||
-rw-r--r-- | core/java/android/text/StaticLayout.java | 9 | ||||
-rw-r--r-- | core/java/android/text/style/LeadingMarginSpan.java | 5 |
3 files changed, 26 insertions, 3 deletions
diff --git a/core/java/android/text/Layout.java b/core/java/android/text/Layout.java index a92800d..afc6864 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); } } } diff --git a/core/java/android/text/StaticLayout.java b/core/java/android/text/StaticLayout.java index f0a5ffd..fbf1261 100644 --- a/core/java/android/text/StaticLayout.java +++ b/core/java/android/text/StaticLayout.java @@ -161,6 +161,7 @@ extends Layout else end++; + int firstWidthLineCount = 1; int firstwidth = outerwidth; int restwidth = outerwidth; @@ -171,8 +172,12 @@ extends Layout sp = spanned.getSpans(start, end, LeadingMarginSpan.class); for (int i = 0; i < sp.length; i++) { + LeadingMarginSpan lms = sp[i]; firstwidth -= sp[i].getLeadingMargin(true); restwidth -= sp[i].getLeadingMargin(false); + if (lms instanceof LeadingMarginSpan.LeadingMarginSpan2) { + firstWidthLineCount = ((LeadingMarginSpan.LeadingMarginSpan2)lms).getLeadingMarginLineCount(); + } } chooseht = spanned.getSpans(start, end, LineHeightSpan.class); @@ -750,7 +755,9 @@ extends Layout fitascent = fitdescent = fittop = fitbottom = 0; okascent = okdescent = oktop = okbottom = 0; - width = restwidth; + if (--firstWidthLineCount <= 0) { + width = restwidth; + } } } } diff --git a/core/java/android/text/style/LeadingMarginSpan.java b/core/java/android/text/style/LeadingMarginSpan.java index 8e212e3..cb55329 100644 --- a/core/java/android/text/style/LeadingMarginSpan.java +++ b/core/java/android/text/style/LeadingMarginSpan.java @@ -33,6 +33,11 @@ extends ParagraphStyle CharSequence text, int start, int end, boolean first, Layout layout); + + public interface LeadingMarginSpan2 extends LeadingMarginSpan, WrapTogetherSpan { + public int getLeadingMarginLineCount(); + }; + public static class Standard implements LeadingMarginSpan, ParcelableSpan { private final int mFirst, mRest; |