1d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd/* 2d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * Copyright (C) 2015 The Android Open Source Project 3d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * 4d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * Licensed under the Apache License, Version 2.0 (the "License"); 5d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * you may not use this file except in compliance with the License. 6d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * You may obtain a copy of the License at 7d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * 8d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * http://www.apache.org/licenses/LICENSE-2.0 9d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * 10d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * Unless required by applicable law or agreed to in writing, software 11d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * distributed under the License is distributed on an "AS IS" BASIS, 12d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * See the License for the specific language governing permissions and 14d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * limitations under the License. 15d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd */ 16d3b009ae55651f1e60950342468e3c37fdeb0796Mike Doddpackage com.android.messaging.ui; 17d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd 18d3b009ae55651f1e60950342468e3c37fdeb0796Mike Doddimport android.content.Context; 19d3b009ae55651f1e60950342468e3c37fdeb0796Mike Doddimport android.util.AttributeSet; 20d3b009ae55651f1e60950342468e3c37fdeb0796Mike Doddimport android.view.Gravity; 21d3b009ae55651f1e60950342468e3c37fdeb0796Mike Doddimport android.view.View; 22d3b009ae55651f1e60950342468e3c37fdeb0796Mike Doddimport android.view.ViewGroup; 23d3b009ae55651f1e60950342468e3c37fdeb0796Mike Doddimport android.widget.FrameLayout; 24d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd 25d3b009ae55651f1e60950342468e3c37fdeb0796Mike Doddimport com.android.messaging.util.OsUtil; 26d3b009ae55651f1e60950342468e3c37fdeb0796Mike Doddimport com.android.messaging.util.UiUtils; 27d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd 28d3b009ae55651f1e60950342468e3c37fdeb0796Mike Doddimport java.util.ArrayList; 29d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd 30d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd/** 31d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd* A line-wrapping flow layout. Arranges children in horizontal flow, packing as many 32d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd* child views as possible on each line. When the current line does not 33d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd* have enough horizontal space, the layout continues on the next line. 34d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd*/ 35d3b009ae55651f1e60950342468e3c37fdeb0796Mike Doddpublic class LineWrapLayout extends ViewGroup { 36d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd public LineWrapLayout(Context context) { 37d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd this(context, null); 38d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd } 39d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd 40d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd public LineWrapLayout(Context context, AttributeSet attrs) { 41d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd super(context, attrs); 42d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd } 43d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd 44d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd @Override 45d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 46d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd final int startPadding = UiUtils.getPaddingStart(this); 47d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd final int endPadding = UiUtils.getPaddingEnd(this); 48d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd final int widthMode = MeasureSpec.getMode(widthMeasureSpec); 49d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd final int widthSize = MeasureSpec.getSize(widthMeasureSpec) - startPadding - endPadding; 50d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd final boolean isFixedSize = (widthMode == MeasureSpec.EXACTLY); 51d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd 52d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd int height = 0; 53d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd 54d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd int childCount = getChildCount(); 55d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd int childWidthSpec = MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.AT_MOST); 56d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd 57d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd int x = startPadding; 58d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd int currLineWidth = 0; 59d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd int currLineHeight = 0; 60d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd int maxLineWidth = 0; 61d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd 62d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd for (int i = 0; i < childCount; i++) { 63d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd View currChild = getChildAt(i); 64d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd if (currChild.getVisibility() == GONE) { 65d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd continue; 66d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd } 67d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd LayoutParams layoutParams = (LayoutParams) currChild.getLayoutParams(); 68d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd int startMargin = layoutParams.getStartMargin(); 69d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd int endMargin = layoutParams.getEndMargin(); 70d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd currChild.measure(childWidthSpec, MeasureSpec.UNSPECIFIED); 71d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd int childMeasuredWidth = currChild.getMeasuredWidth() + startMargin + endMargin; 72d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd int childMeasuredHeight = currChild.getMeasuredHeight() + layoutParams.topMargin + 73d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd layoutParams.bottomMargin; 74d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd 75d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd if ((x + childMeasuredWidth) > widthSize) { 76d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd // New line. Update the overall height and reset trackers. 77d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd height += currLineHeight; 78d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd currLineHeight = 0; 79d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd x = startPadding; 80d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd currLineWidth = 0; 81d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd startMargin = 0; 82d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd } 83d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd 84d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd x += childMeasuredWidth; 85d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd currLineWidth += childMeasuredWidth; 86d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd currLineHeight = Math.max(currLineHeight, childMeasuredHeight); 87d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd maxLineWidth = Math.max(currLineWidth, maxLineWidth); 88d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd } 89d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd // And account for the height of the last line. 90d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd height += currLineHeight; 91d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd 92d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd int width = isFixedSize ? widthSize : maxLineWidth; 93d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd setMeasuredDimension(width + startPadding + endPadding, 94d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd height + getPaddingTop() + getPaddingBottom()); 95d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd } 96d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd 97d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd @Override 98d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd protected void onLayout(boolean changed, int l, int t, int r, int b) { 99d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd final int startPadding = UiUtils.getPaddingStart(this); 100d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd final int endPadding = UiUtils.getPaddingEnd(this); 101d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd int width = getWidth() - startPadding - endPadding; 102d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd int y = getPaddingTop(); 103d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd int x = startPadding; 104d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd int childCount = getChildCount(); 105d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd 106d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd int currLineHeight = 0; 107d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd 108d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd // Do a dry-run first to get the line heights. 109d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd final ArrayList<Integer> lineHeights = new ArrayList<Integer>(); 110d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd for (int i = 0; i < childCount; i++) { 111d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd View currChild = getChildAt(i); 112d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd if (currChild.getVisibility() == GONE) { 113d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd continue; 114d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd } 115d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd LayoutParams layoutParams = (LayoutParams) currChild.getLayoutParams(); 116d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd int childWidth = currChild.getMeasuredWidth(); 117d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd int childHeight = currChild.getMeasuredHeight(); 118d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd int startMargin = layoutParams.getStartMargin(); 119d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd int endMargin = layoutParams.getEndMargin(); 120d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd 121d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd if ((x + childWidth + startMargin + endMargin) > width) { 122d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd // new line 123d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd lineHeights.add(currLineHeight); 124d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd currLineHeight = 0; 125d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd x = startPadding; 126d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd startMargin = 0; 127d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd } 128d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd currLineHeight = Math.max(currLineHeight, childHeight + layoutParams.topMargin + 129d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd layoutParams.bottomMargin); 130d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd x += childWidth + startMargin + endMargin; 131d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd } 132d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd // Add the last line height. 133d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd lineHeights.add(currLineHeight); 134d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd 135d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd // Now perform the actual layout. 136d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd x = startPadding; 137d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd currLineHeight = 0; 138d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd int lineIndex = 0; 139d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd for (int i = 0; i < childCount; i++) { 140d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd View currChild = getChildAt(i); 141d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd if (currChild.getVisibility() == GONE) { 142d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd continue; 143d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd } 144d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd LayoutParams layoutParams = (LayoutParams) currChild.getLayoutParams(); 145d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd int childWidth = currChild.getMeasuredWidth(); 146d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd int childHeight = currChild.getMeasuredHeight(); 147d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd int startMargin = layoutParams.getStartMargin(); 148d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd int endMargin = layoutParams.getEndMargin(); 149d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd 150d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd if ((x + childWidth + startMargin + endMargin) > width) { 151d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd // new line 152d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd y += currLineHeight; 153d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd currLineHeight = 0; 154d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd x = startPadding; 155d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd startMargin = 0; 156d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd lineIndex++; 157d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd } 158d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd final int startPositionX = x + startMargin; 159d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd int startPositionY = y + layoutParams.topMargin; // default to top gravity 160d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd final int majorGravity = layoutParams.gravity & Gravity.VERTICAL_GRAVITY_MASK; 161d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd if (majorGravity != Gravity.TOP && lineHeights.size() > lineIndex) { 162d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd final int lineHeight = lineHeights.get(lineIndex); 163d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd switch (majorGravity) { 164d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd case Gravity.BOTTOM: 165d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd startPositionY = y + lineHeight - childHeight - layoutParams.bottomMargin; 166d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd break; 167d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd 168d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd case Gravity.CENTER_VERTICAL: 169d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd startPositionY = y + (lineHeight - childHeight) / 2; 170d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd break; 171d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd } 172d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd } 173d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd 174d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd if (OsUtil.isAtLeastJB_MR2() && getResources().getConfiguration() 175d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd .getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) { 176d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd currChild.layout(width - startPositionX - childWidth, startPositionY, 177d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd width - startPositionX, startPositionY + childHeight); 178d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd } else { 179d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd currChild.layout(startPositionX, startPositionY, startPositionX + childWidth, 180d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd startPositionY + childHeight); 181d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd } 182d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd currLineHeight = Math.max(currLineHeight, childHeight + layoutParams.topMargin + 183d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd layoutParams.bottomMargin); 184d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd x += childWidth + startMargin + endMargin; 185d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd } 186d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd } 187d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd 188d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd @Override 189d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd protected LayoutParams generateLayoutParams(ViewGroup.LayoutParams p) { 190d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd return new LayoutParams(p); 191d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd } 192d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd 193d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd @Override 194d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd public LayoutParams generateLayoutParams(AttributeSet attrs) { 195d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd return new LayoutParams(getContext(), attrs); 196d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd } 197d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd 198d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd @Override 199d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd protected LayoutParams generateDefaultLayoutParams() { 200d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd return new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); 201d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd } 202d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd 203d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd public static final class LayoutParams extends FrameLayout.LayoutParams { 204d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd public LayoutParams(Context c, AttributeSet attrs) { 205d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd super(c, attrs); 206d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd } 207d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd 208d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd public LayoutParams(int width, int height) { 209d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd super(width, height); 210d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd } 211d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd 212d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd public LayoutParams(ViewGroup.LayoutParams source) { 213d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd super(source); 214d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd } 215d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd 216d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd public int getStartMargin() { 217d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd if (OsUtil.isAtLeastJB_MR2()) { 218d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd return getMarginStart(); 219d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd } else { 220d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd return leftMargin; 221d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd } 222d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd } 223d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd 224d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd public int getEndMargin() { 225d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd if (OsUtil.isAtLeastJB_MR2()) { 226d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd return getMarginEnd(); 227d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd } else { 228d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd return rightMargin; 229d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd } 230d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd } 231d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd } 232d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd} 233