summaryrefslogtreecommitdiffstats
path: root/core/java/android
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/android')
-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.java11
-rw-r--r--core/java/android/widget/TimePicker.java36
5 files changed, 83 insertions, 62 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 e7c33ab..8cb725a 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -5779,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) {
@@ -7365,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();
}
}
@@ -8888,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;
}
@@ -9036,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();
}