summaryrefslogtreecommitdiffstats
path: root/core/java
diff options
context:
space:
mode:
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/content/res/CompatibilityInfo.java10
-rw-r--r--core/java/android/view/View.java2
-rw-r--r--core/java/android/widget/TabWidget.java86
-rw-r--r--core/java/android/widget/TextView.java52
-rw-r--r--core/java/android/widget/TimePicker.java36
-rw-r--r--core/java/com/android/internal/app/ActionBarImpl.java6
6 files changed, 110 insertions, 82 deletions
diff --git a/core/java/android/content/res/CompatibilityInfo.java b/core/java/android/content/res/CompatibilityInfo.java
index 6baf1c2..e403ac2 100644
--- a/core/java/android/content/res/CompatibilityInfo.java
+++ b/core/java/android/content/res/CompatibilityInfo.java
@@ -141,10 +141,16 @@ public class CompatibilityInfo {
appFlags = appInfo.flags;
if ((appInfo.flags & ApplicationInfo.FLAG_SUPPORTS_LARGE_SCREENS) != 0) {
- mCompatibilityFlags |= LARGE_SCREENS | CONFIGURED_LARGE_SCREENS;
+ // Saying you support large screens also implies you support xlarge
+ // screens; there is no compatibility mode for a large app on an
+ // xlarge screen.
+ mCompatibilityFlags |= LARGE_SCREENS | CONFIGURED_LARGE_SCREENS
+ | XLARGE_SCREENS | CONFIGURED_XLARGE_SCREENS
+ | EXPANDABLE | CONFIGURED_EXPANDABLE;
}
if ((appInfo.flags & ApplicationInfo.FLAG_SUPPORTS_XLARGE_SCREENS) != 0) {
- mCompatibilityFlags |= XLARGE_SCREENS | CONFIGURED_XLARGE_SCREENS;
+ mCompatibilityFlags |= XLARGE_SCREENS | CONFIGURED_XLARGE_SCREENS
+ | EXPANDABLE | CONFIGURED_EXPANDABLE;
}
if ((appInfo.flags & ApplicationInfo.FLAG_RESIZEABLE_FOR_SCREENS) != 0) {
mCompatibilityFlags |= EXPANDABLE | CONFIGURED_EXPANDABLE;
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index f111f98..f9629bd 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -10940,7 +10940,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
public void dispatchSystemUiVisibilityChanged(int visibility) {
if (mOnSystemUiVisibilityChangeListener != null) {
mOnSystemUiVisibilityChangeListener.onSystemUiVisibilityChange(
- visibility & ~PUBLIC_STATUS_BAR_VISIBILITY_MASK);
+ visibility & PUBLIC_STATUS_BAR_VISIBILITY_MASK);
}
}
diff --git a/core/java/android/widget/TabWidget.java b/core/java/android/widget/TabWidget.java
index 1a4ff29..22f6f4e 100644
--- a/core/java/android/widget/TabWidget.java
+++ b/core/java/android/widget/TabWidget.java
@@ -66,6 +66,10 @@ public class TabWidget extends LinearLayout implements OnFocusChangeListener {
private final Rect mBounds = new Rect();
+ // When positive, the widths and heights of tabs will be imposed so that they fit in parent
+ private int mImposedTabsHeight = -1;
+ private int[] mImposedTabWidths;
+
public TabWidget(Context context) {
this(context, null);
}
@@ -150,52 +154,62 @@ public class TabWidget extends LinearLayout implements OnFocusChangeListener {
setOnFocusChangeListener(this);
}
- /**
- * {@inheritDoc}
- */
+ @Override
+ void measureChildBeforeLayout(View child, int childIndex,
+ int widthMeasureSpec, int totalWidth,
+ int heightMeasureSpec, int totalHeight) {
+
+ if (mImposedTabsHeight >= 0) {
+ widthMeasureSpec = MeasureSpec.makeMeasureSpec(
+ totalWidth + mImposedTabWidths[childIndex], MeasureSpec.EXACTLY);
+ heightMeasureSpec = MeasureSpec.makeMeasureSpec(mImposedTabsHeight,
+ MeasureSpec.EXACTLY);
+ }
+
+ super.measureChildBeforeLayout(child, childIndex,
+ widthMeasureSpec, totalWidth, heightMeasureSpec, totalHeight);
+ }
+
@Override
void measureHorizontal(int widthMeasureSpec, int heightMeasureSpec) {
- // First measure with no constraint
+ // First, measure with no constraint
final int unspecifiedWidth = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
super.measureHorizontal(unspecifiedWidth, heightMeasureSpec);
+ mImposedTabsHeight = -1;
- final int count = getChildCount();
- int totalWidth = 0;
- int totalCount = 0;
- for (int i = 0; i < count; i++) {
- final View child = getChildAt(i);
- if (child.getVisibility() == GONE) {
- continue;
- }
- final int childWidth = child.getMeasuredWidth();
- totalWidth += childWidth;
- totalCount++;
- }
+ int extraWidth = getMeasuredWidth() - MeasureSpec.getSize(widthMeasureSpec);
+ if (extraWidth > 0) {
+ final int count = getChildCount();
- final int width = MeasureSpec.getSize(widthMeasureSpec);
- if (totalWidth > width && totalCount > 0) {
- int extraWidth = totalWidth - width;
+ int childCount = 0;
for (int i = 0; i < count; i++) {
final View child = getChildAt(i);
- if (child.getVisibility() == GONE) {
- continue;
- }
- final int childWidth = child.getMeasuredWidth();
- final int delta = extraWidth / totalCount;
- final int tabWidth = Math.max(0, childWidth - delta);
-
- final int tabWidthMeasureSpec = MeasureSpec.makeMeasureSpec(
- tabWidth, MeasureSpec.EXACTLY);
- final int tabHeightMeasureSpec = MeasureSpec.makeMeasureSpec(
- child.getMeasuredHeight(), MeasureSpec.EXACTLY);
-
- child.measure(tabWidthMeasureSpec, tabHeightMeasureSpec);
+ if (child.getVisibility() == GONE) continue;
+ childCount++;
+ }
- // Make sure the extra width is evenly distributed, avoiding int division remainder
- extraWidth -= delta;
- totalCount--;
+ if (childCount > 0) {
+ if (mImposedTabWidths == null || mImposedTabWidths.length != count) {
+ mImposedTabWidths = new int[count];
+ }
+ for (int i = 0; i < count; i++) {
+ final View child = getChildAt(i);
+ if (child.getVisibility() == GONE) continue;
+ final int childWidth = child.getMeasuredWidth();
+ final int delta = extraWidth / childCount;
+ final int newWidth = Math.max(0, childWidth - delta);
+ mImposedTabWidths[i] = newWidth;
+ // Make sure the extra width is evenly distributed, no int division remainder
+ extraWidth -= childWidth - newWidth; // delta may have been clamped
+ childCount--;
+ mImposedTabsHeight = Math.max(mImposedTabsHeight, child.getMeasuredHeight());
+ }
}
- setMeasuredDimension(width, getMeasuredHeight());
+ }
+
+ // Measure again, this time with imposed tab widths and respecting initial spec request
+ if (mImposedTabsHeight >= 0 || unspecifiedWidth != widthMeasureSpec) {
+ super.measureHorizontal(widthMeasureSpec, heightMeasureSpec);
}
}
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index eee042a..8cb725a 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -3489,8 +3489,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
com.android.internal.R.layout.textview_hint, null);
final float scale = getResources().getDisplayMetrics().density;
- mPopup = new ErrorPopup(err, (int) (200 * scale + 0.5f),
- (int) (50 * scale + 0.5f));
+ mPopup = new ErrorPopup(err, (int) (200 * scale + 0.5f), (int) (50 * scale + 0.5f));
mPopup.setFocusable(false);
// The user is entering text, so the input method is needed. We
// don't want the popup to be displayed on top of it.
@@ -3514,6 +3513,12 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
ErrorPopup(TextView v, int width, int height) {
super(v, width, height);
mView = v;
+ // Make sure the TextView has a background set as it will be used the first time it is
+ // shown and positionned. Initialized with below background, which should have
+ // dimensions identical to the above version for this to work (and is more likely).
+ mPopupInlineErrorBackgroundId = getResourceId(mPopupInlineErrorBackgroundId,
+ com.android.internal.R.styleable.Theme_errorMessageBackground);
+ mView.setBackgroundResource(mPopupInlineErrorBackgroundId);
}
void fixDirection(boolean above) {
@@ -3521,18 +3526,21 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
if (above) {
mPopupInlineErrorAboveBackgroundId =
- getResourceId(mPopupInlineErrorAboveBackgroundId, com.android.internal.R.styleable.Theme_errorMessageAboveBackground);
+ getResourceId(mPopupInlineErrorAboveBackgroundId,
+ com.android.internal.R.styleable.Theme_errorMessageAboveBackground);
} else {
- mPopupInlineErrorBackgroundId =
- getResourceId(mPopupInlineErrorBackgroundId, com.android.internal.R.styleable.Theme_errorMessageBackground);
+ mPopupInlineErrorBackgroundId = getResourceId(mPopupInlineErrorBackgroundId,
+ com.android.internal.R.styleable.Theme_errorMessageBackground);
}
- mView.setBackgroundResource(above ? mPopupInlineErrorAboveBackgroundId : mPopupInlineErrorBackgroundId);
+ mView.setBackgroundResource(above ? mPopupInlineErrorAboveBackgroundId :
+ mPopupInlineErrorBackgroundId);
}
private int getResourceId(int currentId, int index) {
if (currentId == 0) {
- TypedArray styledAttributes = mView.getContext().obtainStyledAttributes(R.styleable.Theme);
+ TypedArray styledAttributes = mView.getContext().obtainStyledAttributes(
+ R.styleable.Theme);
currentId = styledAttributes.getResourceId(index, 0);
styledAttributes.recycle();
}
@@ -3562,9 +3570,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
final float scale = getResources().getDisplayMetrics().density;
final Drawables dr = mDrawables;
- return getWidth() - mPopup.getWidth()
- - getPaddingRight()
- - (dr != null ? dr.mDrawableSizeRight : 0) / 2 + (int) (25 * scale + 0.5f);
+ return getWidth() - mPopup.getWidth() - getPaddingRight() -
+ (dr != null ? dr.mDrawableSizeRight : 0) / 2 + (int) (25 * scale + 0.5f);
}
/**
@@ -3576,20 +3583,20 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
* Compound, not extended, because the icon is not clipped
* if the text height is smaller.
*/
- int vspace = mBottom - mTop -
- getCompoundPaddingBottom() - getCompoundPaddingTop();
+ final int compoundPaddingTop = getCompoundPaddingTop();
+ int vspace = mBottom - mTop - getCompoundPaddingBottom() - compoundPaddingTop;
final Drawables dr = mDrawables;
- int icontop = getCompoundPaddingTop()
- + (vspace - (dr != null ? dr.mDrawableHeightRight : 0)) / 2;
+ int icontop = compoundPaddingTop +
+ (vspace - (dr != null ? dr.mDrawableHeightRight : 0)) / 2;
/*
* The "2" is the distance between the point and the top edge
* of the background.
*/
-
- return icontop + (dr != null ? dr.mDrawableHeightRight : 0)
- - getHeight() - 2;
+ final float scale = getResources().getDisplayMetrics().density;
+ return icontop + (dr != null ? dr.mDrawableHeightRight : 0) - getHeight() -
+ (int) (2 * scale + 0.5f);
}
private void hideError() {
@@ -5772,11 +5779,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
int want = width - getCompoundPaddingLeft() - getCompoundPaddingRight();
int unpaddedWidth = want;
- int hintWant = want;
- if (mHorizontallyScrolling)
- want = VERY_WIDE;
+ if (mHorizontallyScrolling) want = VERY_WIDE;
+ int hintWant = want;
int hintWidth = mHintLayout == null ? hintWant : mHintLayout.getWidth();
if (mLayout == null) {
@@ -7358,7 +7364,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
stopSelectionActionMode();
boolean selectAllGotFocus = mSelectAllOnFocus && mTouchFocusSelected;
- if (hasInsertionController() && !selectAllGotFocus) {
+ if (hasInsertionController() && !selectAllGotFocus && mText.length() > 0) {
getInsertionController().show();
}
}
@@ -8881,6 +8887,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
mLastParentX = coords[0];
mLastParentY = coords[1];
mIsDragging = true;
+ if (mIsInsertionHandle) {
+ mTouchTimer = SystemClock.uptimeMillis();
+ }
break;
}
@@ -9029,6 +9038,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
if (offset != previousOffset) {
updateOffset(handle, offset);
+ removePastePopupCallback();
}
hideDelayed();
}
diff --git a/core/java/android/widget/TimePicker.java b/core/java/android/widget/TimePicker.java
index 4b37beb..18d1825 100644
--- a/core/java/android/widget/TimePicker.java
+++ b/core/java/android/widget/TimePicker.java
@@ -132,12 +132,8 @@ public class TimePicker extends FrameLayout {
mHourSpinner.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() {
public void onValueChange(NumberPicker spinner, int oldVal, int newVal) {
if (!is24HourView()) {
- int minValue = mHourSpinner.getMinValue();
- int maxValue = mHourSpinner.getMaxValue();
- // toggle AM/PM if the spinner has wrapped and not in 24
- // format
- if ((oldVal == maxValue && newVal == minValue)
- || (oldVal == minValue && newVal == maxValue)) {
+ if ((oldVal == HOURS_IN_HALF_DAY - 1 && newVal == HOURS_IN_HALF_DAY)
+ || (oldVal == HOURS_IN_HALF_DAY && newVal == HOURS_IN_HALF_DAY - 1)) {
mIsAm = !mIsAm;
updateAmPmControl();
}
@@ -163,21 +159,19 @@ public class TimePicker extends FrameLayout {
int minValue = mMinuteSpinner.getMinValue();
int maxValue = mMinuteSpinner.getMaxValue();
if (oldVal == maxValue && newVal == minValue) {
- int currentHour = mHourSpinner.getValue();
- // toggle AM/PM if the spinner is about to wrap
- if (!is24HourView() && currentHour == mHourSpinner.getMaxValue()) {
+ int newHour = mHourSpinner.getValue() + 1;
+ if (!is24HourView() && newHour == HOURS_IN_HALF_DAY) {
mIsAm = !mIsAm;
updateAmPmControl();
}
- mHourSpinner.setValue(currentHour + 1);
+ mHourSpinner.setValue(newHour);
} else if (oldVal == minValue && newVal == maxValue) {
- int currentHour = mHourSpinner.getValue();
- // toggle AM/PM if the spinner is about to wrap
- if (!is24HourView() && currentHour == mHourSpinner.getMinValue()) {
+ int newHour = mHourSpinner.getValue() - 1;
+ if (!is24HourView() && newHour == HOURS_IN_HALF_DAY - 1) {
mIsAm = !mIsAm;
updateAmPmControl();
}
- mHourSpinner.setValue(currentHour - 1);
+ mHourSpinner.setValue(newHour);
}
onTimeChanged();
}
@@ -330,10 +324,12 @@ public class TimePicker extends FrameLayout {
*/
public Integer getCurrentHour() {
int currentHour = mHourSpinner.getValue();
- if (is24HourView() || mIsAm) {
+ if (is24HourView()) {
return currentHour;
+ } else if (mIsAm) {
+ return currentHour % HOURS_IN_HALF_DAY;
} else {
- return (currentHour == HOURS_IN_HALF_DAY) ? 0 : currentHour + HOURS_IN_HALF_DAY;
+ return (currentHour % HOURS_IN_HALF_DAY) + HOURS_IN_HALF_DAY;
}
}
@@ -347,14 +343,16 @@ public class TimePicker extends FrameLayout {
}
if (!is24HourView()) {
// convert [0,23] ordinal to wall clock display
- if (currentHour > HOURS_IN_HALF_DAY) {
- currentHour -= HOURS_IN_HALF_DAY;
+ if (currentHour >= HOURS_IN_HALF_DAY) {
mIsAm = false;
+ if (currentHour > HOURS_IN_HALF_DAY) {
+ currentHour = currentHour - HOURS_IN_HALF_DAY;
+ }
} else {
+ mIsAm = true;
if (currentHour == 0) {
currentHour = HOURS_IN_HALF_DAY;
}
- mIsAm = true;
}
updateAmPmControl();
}
diff --git a/core/java/com/android/internal/app/ActionBarImpl.java b/core/java/com/android/internal/app/ActionBarImpl.java
index b1b5d71..471a5a9 100644
--- a/core/java/com/android/internal/app/ActionBarImpl.java
+++ b/core/java/com/android/internal/app/ActionBarImpl.java
@@ -480,12 +480,12 @@ public class ActionBarImpl extends ActionBar {
@Override
public void show() {
- if (mContainerView.getVisibility() == View.VISIBLE) {
- return;
- }
if (mCurrentAnim != null) {
mCurrentAnim.end();
}
+ if (mContainerView.getVisibility() == View.VISIBLE) {
+ return;
+ }
mContainerView.setVisibility(View.VISIBLE);
mContainerView.setAlpha(0);
AnimatorSet anim = new AnimatorSet();