summaryrefslogtreecommitdiffstats
path: root/core/java
diff options
context:
space:
mode:
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/app/AlertDialog.java16
-rw-r--r--core/java/android/app/ContextImpl.java3
-rw-r--r--core/java/android/app/DialogFragment.java2
-rwxr-xr-xcore/java/android/content/res/Resources.java12
-rw-r--r--core/java/android/inputmethodservice/InputMethodService.java4
-rw-r--r--core/java/android/os/Build.java9
-rw-r--r--core/java/android/text/DynamicLayout.java16
-rw-r--r--core/java/android/view/InputChannel.java7
-rw-r--r--core/java/android/view/View.java30
-rw-r--r--core/java/android/widget/AbsSeekBar.java53
-rw-r--r--core/java/android/widget/SeekBar.java2
-rw-r--r--core/java/android/widget/TextView.java41
12 files changed, 149 insertions, 46 deletions
diff --git a/core/java/android/app/AlertDialog.java b/core/java/android/app/AlertDialog.java
index 491fcfe..c09e87f 100644
--- a/core/java/android/app/AlertDialog.java
+++ b/core/java/android/app/AlertDialog.java
@@ -75,6 +75,18 @@ public class AlertDialog extends Dialog implements DialogInterface {
* the holographic alert theme with a light background.
*/
public static final int THEME_HOLO_LIGHT = 3;
+
+ /**
+ * Special theme constant for {@link #AlertDialog(Context, int)}: use
+ * the device's default alert theme with a dark background.
+ */
+ public static final int THEME_DEVICE_DEFAULT_DARK = 4;
+
+ /**
+ * Special theme constant for {@link #AlertDialog(Context, int)}: use
+ * the device's default alert theme with a dark background.
+ */
+ public static final int THEME_DEVICE_DEFAULT_LIGHT = 5;
protected AlertDialog(Context context) {
this(context, resolveDialogTheme(context, 0), true);
@@ -113,6 +125,10 @@ public class AlertDialog extends Dialog implements DialogInterface {
return com.android.internal.R.style.Theme_Holo_Dialog_Alert;
} else if (resid == THEME_HOLO_LIGHT) {
return com.android.internal.R.style.Theme_Holo_Light_Dialog_Alert;
+ } else if (resid == THEME_DEVICE_DEFAULT_DARK) {
+ return com.android.internal.R.style.Theme_DeviceDefault_Dialog_Alert;
+ } else if (resid == THEME_DEVICE_DEFAULT_LIGHT) {
+ return com.android.internal.R.style.Theme_DeviceDefault_Light_Dialog_Alert;
} else if (resid >= 0x01000000) { // start of real resource IDs.
return resid;
} else {
diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java
index b4bdb2f..2139704 100644
--- a/core/java/android/app/ContextImpl.java
+++ b/core/java/android/app/ContextImpl.java
@@ -364,7 +364,8 @@ class ContextImpl extends Context {
Resources.selectSystemTheme(0,
outerContext.getApplicationInfo().targetSdkVersion,
com.android.internal.R.style.Theme_Dialog,
- com.android.internal.R.style.Theme_Holo_Dialog)),
+ com.android.internal.R.style.Theme_Holo_Dialog,
+ com.android.internal.R.style.Theme_DeviceDefault_Dialog)),
ctx.mMainThread.getHandler());
}});
diff --git a/core/java/android/app/DialogFragment.java b/core/java/android/app/DialogFragment.java
index cce7cd6..8921578 100644
--- a/core/java/android/app/DialogFragment.java
+++ b/core/java/android/app/DialogFragment.java
@@ -204,7 +204,7 @@ public class DialogFragment extends Fragment
public void setStyle(int style, int theme) {
mStyle = style;
if (mStyle == STYLE_NO_FRAME || mStyle == STYLE_NO_INPUT) {
- mTheme = com.android.internal.R.style.Theme_Holo_Dialog_NoFrame;
+ mTheme = com.android.internal.R.style.Theme_DeviceDefault_Dialog_NoFrame;
}
if (theme != 0) {
mTheme = theme;
diff --git a/core/java/android/content/res/Resources.java b/core/java/android/content/res/Resources.java
index f526923..24f8319 100755
--- a/core/java/android/content/res/Resources.java
+++ b/core/java/android/content/res/Resources.java
@@ -134,18 +134,24 @@ public class Resources {
/** @hide */
public static int selectDefaultTheme(int curTheme, int targetSdkVersion) {
return selectSystemTheme(curTheme, targetSdkVersion,
- com.android.internal.R.style.Theme, com.android.internal.R.style.Theme_Holo);
+ com.android.internal.R.style.Theme,
+ com.android.internal.R.style.Theme_Holo,
+ com.android.internal.R.style.Theme_DeviceDefault);
}
/** @hide */
- public static int selectSystemTheme(int curTheme, int targetSdkVersion, int orig, int holo) {
+ public static int selectSystemTheme(int curTheme, int targetSdkVersion,
+ int orig, int holo, int deviceDefault) {
if (curTheme != 0) {
return curTheme;
}
if (targetSdkVersion < Build.VERSION_CODES.HONEYCOMB) {
return orig;
}
- return holo;
+ if (targetSdkVersion < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
+ return holo;
+ }
+ return deviceDefault;
}
/**
diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java
index 9481a88..370e22a 100644
--- a/core/java/android/inputmethodservice/InputMethodService.java
+++ b/core/java/android/inputmethodservice/InputMethodService.java
@@ -617,7 +617,9 @@ public class InputMethodService extends AbstractInputMethodService {
@Override public void onCreate() {
mTheme = Resources.selectSystemTheme(mTheme,
getApplicationInfo().targetSdkVersion,
- android.R.style.Theme_InputMethod, android.R.style.Theme_Holo_InputMethod);
+ android.R.style.Theme_InputMethod,
+ android.R.style.Theme_Holo,
+ android.R.style.Theme_DeviceDefault_InputMethod);
super.setTheme(mTheme);
super.onCreate();
mImm = (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
diff --git a/core/java/android/os/Build.java b/core/java/android/os/Build.java
index 6c7c58d..1e9ee7c 100644
--- a/core/java/android/os/Build.java
+++ b/core/java/android/os/Build.java
@@ -287,6 +287,15 @@ public class Build {
* {@link android.R.attr#hardwareAccelerated android:hardwareAccelerated}
* to turn it off if needed, although this is strongly discouraged since
* it will result in poor performance on larger screen devices.
+ * <li> The default theme for applications is now the "device default" theme:
+ * {@link android.R.style#Theme_DeviceDefault}. This may be the
+ * holo dark theme or a different dark theme defined by the specific device.
+ * The {@link android.R.style#Theme_Holo} family must not be modified
+ * for a device to be considered compatible. Applications that explicitly
+ * request a theme from the Holo family will be guaranteed that these themes
+ * will not change character within the same platform version. Applications
+ * that wish to blend in with the device should use a theme from the
+ * {@link android.R.style#Theme_DeviceDefault} family.
* </ul>
*/
public static final int ICE_CREAM_SANDWICH = CUR_DEVELOPMENT;
diff --git a/core/java/android/text/DynamicLayout.java b/core/java/android/text/DynamicLayout.java
index 4f42659..2c78679 100644
--- a/core/java/android/text/DynamicLayout.java
+++ b/core/java/android/text/DynamicLayout.java
@@ -268,11 +268,10 @@ extends Layout
// generate new layout for affected text
StaticLayout reflowed;
- WeakReference<StaticLayout> layoutRef;
+
synchronized (sLock) {
- layoutRef = sStaticLayoutRef;
- reflowed = sStaticLayoutRef != null ? sStaticLayoutRef.get() : null;
- sStaticLayoutRef = null;
+ reflowed = sStaticLayout;
+ sStaticLayout = null;
}
if (reflowed == null) {
@@ -359,12 +358,8 @@ extends Layout
}
synchronized (sLock) {
+ sStaticLayout = reflowed;
reflowed.finish();
- if (layoutRef == null || layoutRef.get() != reflowed) {
- sStaticLayoutRef = new WeakReference<StaticLayout>(reflowed);
- } else {
- sStaticLayoutRef = layoutRef;
- }
}
}
@@ -493,8 +488,7 @@ extends Layout
private int mTopPadding, mBottomPadding;
- private static WeakReference<StaticLayout> sStaticLayoutRef = new WeakReference<StaticLayout>(
- new StaticLayout(true));
+ private static StaticLayout sStaticLayout = new StaticLayout(true);
private static final Object[] sLock = new Object[0];
private static final int START = 0;
diff --git a/core/java/android/view/InputChannel.java b/core/java/android/view/InputChannel.java
index f2cad2f..523af04 100644
--- a/core/java/android/view/InputChannel.java
+++ b/core/java/android/view/InputChannel.java
@@ -48,8 +48,6 @@ public final class InputChannel implements Parcelable {
@SuppressWarnings("unused")
private int mPtr; // used by native code
- private boolean mDisposeAfterWriteToParcel;
-
private static native InputChannel[] nativeOpenInputChannelPair(String name);
private native void nativeDispose(boolean finalized);
@@ -117,13 +115,12 @@ public final class InputChannel implements Parcelable {
* as an out parameter in a binder call.
* @param other The other input channel instance.
*/
- public void transferToBinderOutParameter(InputChannel outParameter) {
+ public void transferTo(InputChannel outParameter) {
if (outParameter == null) {
throw new IllegalArgumentException("outParameter must not be null");
}
nativeTransferTo(outParameter);
- outParameter.mDisposeAfterWriteToParcel = true;
}
public int describeContents() {
@@ -145,7 +142,7 @@ public final class InputChannel implements Parcelable {
nativeWriteToParcel(out);
- if (mDisposeAfterWriteToParcel) {
+ if ((flags & PARCELABLE_WRITE_RETURN_VALUE) != 0) {
dispose();
}
}
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 5b77cf7..54bd637 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -6249,15 +6249,7 @@ public class View implements Drawable.Callback2, KeyEvent.Callback, Accessibilit
}
// Walk up the hierarchy to determine if we're inside a scrolling container.
- boolean isInScrollingContainer = false;
- ViewParent p = getParent();
- while (p != null && p instanceof ViewGroup) {
- if (((ViewGroup) p).shouldDelayChildPressedState()) {
- isInScrollingContainer = true;
- break;
- }
- p = p.getParent();
- }
+ boolean isInScrollingContainer = isInScrollingContainer();
// For views inside a scrolling container, delay the pressed feedback for
// a short period in case this is a scroll.
@@ -6307,6 +6299,20 @@ public class View implements Drawable.Callback2, KeyEvent.Callback, Accessibilit
}
/**
+ * @hide
+ */
+ public boolean isInScrollingContainer() {
+ ViewParent p = getParent();
+ while (p != null && p instanceof ViewGroup) {
+ if (((ViewGroup) p).shouldDelayChildPressedState()) {
+ return true;
+ }
+ p = p.getParent();
+ }
+ return false;
+ }
+
+ /**
* Remove the longpress detection timer.
*/
private void removeLongPressCallback() {
@@ -8774,6 +8780,12 @@ public class View implements Drawable.Callback2, KeyEvent.Callback, Accessibilit
* @see #SCROLLBARS_OUTSIDE_OVERLAY
* @see #SCROLLBARS_OUTSIDE_INSET
*/
+ @ViewDebug.ExportedProperty(mapping = {
+ @ViewDebug.IntToString(from = SCROLLBARS_INSIDE_OVERLAY, to = "INSIDE_OVERLAY"),
+ @ViewDebug.IntToString(from = SCROLLBARS_INSIDE_INSET, to = "INSIDE_INSET"),
+ @ViewDebug.IntToString(from = SCROLLBARS_OUTSIDE_OVERLAY, to = "OUTSIDE_OVERLAY"),
+ @ViewDebug.IntToString(from = SCROLLBARS_OUTSIDE_INSET, to = "OUTSIDE_INSET")
+ })
public int getScrollBarStyle() {
return mViewFlags & SCROLLBARS_STYLE_MASK;
}
diff --git a/core/java/android/widget/AbsSeekBar.java b/core/java/android/widget/AbsSeekBar.java
index 2621e64..df8eb05 100644
--- a/core/java/android/widget/AbsSeekBar.java
+++ b/core/java/android/widget/AbsSeekBar.java
@@ -24,6 +24,7 @@ import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.MotionEvent;
+import android.view.ViewConfiguration;
public abstract class AbsSeekBar extends ProgressBar {
private Drawable mThumb;
@@ -49,6 +50,10 @@ public abstract class AbsSeekBar extends ProgressBar {
private static final int NO_ALPHA = 0xFF;
private float mDisabledAlpha;
+ private int mScaledTouchSlop;
+ private float mTouchDownX;
+ private boolean mIsDragging;
+
public AbsSeekBar(Context context) {
super(context);
}
@@ -74,6 +79,8 @@ public abstract class AbsSeekBar extends ProgressBar {
com.android.internal.R.styleable.Theme, 0, 0);
mDisabledAlpha = a.getFloat(com.android.internal.R.styleable.Theme_disabledAlpha, 0.5f);
a.recycle();
+
+ mScaledTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
}
/**
@@ -324,20 +331,42 @@ public abstract class AbsSeekBar extends ProgressBar {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
- setPressed(true);
- onStartTrackingTouch();
- trackTouchEvent(event);
+ if (isInScrollingContainer()) {
+ mTouchDownX = event.getX();
+ } else {
+ setPressed(true);
+ onStartTrackingTouch();
+ trackTouchEvent(event);
+ attemptClaimDrag();
+ }
break;
case MotionEvent.ACTION_MOVE:
- trackTouchEvent(event);
- attemptClaimDrag();
+ if (mIsDragging) {
+ trackTouchEvent(event);
+ } else {
+ final float x = event.getX();
+ if (Math.abs(x - mTouchDownX) > mScaledTouchSlop) {
+ setPressed(true);
+ onStartTrackingTouch();
+ trackTouchEvent(event);
+ attemptClaimDrag();
+ }
+ }
break;
case MotionEvent.ACTION_UP:
- trackTouchEvent(event);
- onStopTrackingTouch();
- setPressed(false);
+ if (mIsDragging) {
+ trackTouchEvent(event);
+ onStopTrackingTouch();
+ setPressed(false);
+ } else {
+ // Touch up when we never crossed the touch slop threshold should
+ // be interpreted as a tap-seek to that location.
+ onStartTrackingTouch();
+ trackTouchEvent(event);
+ onStopTrackingTouch();
+ }
// ProgressBar doesn't know to repaint the thumb drawable
// in its inactive state when the touch stops (because the
// value has not apparently changed)
@@ -345,8 +374,10 @@ public abstract class AbsSeekBar extends ProgressBar {
break;
case MotionEvent.ACTION_CANCEL:
- onStopTrackingTouch();
- setPressed(false);
+ if (mIsDragging) {
+ onStopTrackingTouch();
+ setPressed(false);
+ }
invalidate(); // see above explanation
break;
}
@@ -388,6 +419,7 @@ public abstract class AbsSeekBar extends ProgressBar {
* This is called when the user has started touching this widget.
*/
void onStartTrackingTouch() {
+ mIsDragging = true;
}
/**
@@ -395,6 +427,7 @@ public abstract class AbsSeekBar extends ProgressBar {
* canceled.
*/
void onStopTrackingTouch() {
+ mIsDragging = false;
}
/**
diff --git a/core/java/android/widget/SeekBar.java b/core/java/android/widget/SeekBar.java
index dfee29b..c76728f 100644
--- a/core/java/android/widget/SeekBar.java
+++ b/core/java/android/widget/SeekBar.java
@@ -104,6 +104,7 @@ public class SeekBar extends AbsSeekBar {
@Override
void onStartTrackingTouch() {
+ super.onStartTrackingTouch();
if (mOnSeekBarChangeListener != null) {
mOnSeekBarChangeListener.onStartTrackingTouch(this);
}
@@ -111,6 +112,7 @@ public class SeekBar extends AbsSeekBar {
@Override
void onStopTrackingTouch() {
+ super.onStopTrackingTouch();
if (mOnSeekBarChangeListener != null) {
mOnSeekBarChangeListener.onStopTrackingTouch(this);
}
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index d78050a..1ab1a87 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -139,6 +139,11 @@ import com.android.internal.widget.EditableInputConnection;
import org.xmlpull.v1.XmlPullParserException;
+import com.android.internal.util.FastMath;
+import com.android.internal.widget.EditableInputConnection;
+
+import org.xmlpull.v1.XmlPullParserException;
+
import java.io.IOException;
import java.lang.ref.WeakReference;
import java.text.BreakIterator;
@@ -220,6 +225,7 @@ import java.util.HashMap;
* @attr ref android.R.styleable#TextView_imeActionLabel
* @attr ref android.R.styleable#TextView_imeActionId
* @attr ref android.R.styleable#TextView_editorExtras
+ * @attr ref android.R.styleable#TextView_suggestionsEnabled
*/
@RemoteView
public class TextView extends View implements ViewTreeObserver.OnPreDrawListener {
@@ -9418,7 +9424,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
}
void showSuggestions() {
- if (!mSuggestionsEnabled || !isTextEditable()) return;
+ if (!isSuggestionsEnabled() || !isTextEditable()) return;
if (mSuggestionsPopupWindow == null) {
mSuggestionsPopupWindow = new SuggestionsPopupWindow();
@@ -9445,18 +9451,41 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
* user double taps on these parts of the text. No suggestions are displayed when this value is
* false. Use {@link #setSuggestionsEnabled(boolean)} to change this value.
*
+ * Note that suggestions are only enabled for a subset of input types. In addition to setting
+ * this flag to <code>true</code> using {@link #setSuggestionsEnabled(boolean)} or the
+ * <code>android:suggestionsEnabled</code> xml attribute, this method will return
+ * <code>true</code> only if the class of your input type is {@link InputType#TYPE_CLASS_TEXT}.
+ * In addition, the type variation must also be one of
+ * {@link InputType#TYPE_TEXT_VARIATION_NORMAL},
+ * {@link InputType#TYPE_TEXT_VARIATION_EMAIL_SUBJECT},
+ * {@link InputType#TYPE_TEXT_VARIATION_LONG_MESSAGE},
+ * {@link InputType#TYPE_TEXT_VARIATION_SHORT_MESSAGE} or
+ * {@link InputType#TYPE_TEXT_VARIATION_WEB_EDIT_TEXT}.
+ *
* @return true if the suggestions popup window is enabled.
*
* @attr ref android.R.styleable#TextView_suggestionsEnabled
*/
public boolean isSuggestionsEnabled() {
- return mSuggestionsEnabled;
+ if (!mSuggestionsEnabled) return false;
+ if ((mInputType & InputType.TYPE_MASK_CLASS) != InputType.TYPE_CLASS_TEXT) return false;
+ final int variation =
+ mInputType & (EditorInfo.TYPE_MASK_CLASS | EditorInfo.TYPE_MASK_VARIATION);
+ if (variation == EditorInfo.TYPE_TEXT_VARIATION_NORMAL ||
+ variation == EditorInfo.TYPE_TEXT_VARIATION_EMAIL_SUBJECT ||
+ variation == EditorInfo.TYPE_TEXT_VARIATION_LONG_MESSAGE ||
+ variation == EditorInfo.TYPE_TEXT_VARIATION_SHORT_MESSAGE ||
+ variation == EditorInfo.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT) return true;
+
+ return false;
}
/**
* Enables or disables the suggestion popup. See {@link #isSuggestionsEnabled()}.
*
* @param enabled Whether or not suggestions are enabled.
+ *
+ * @attr ref android.R.styleable#TextView_suggestionsEnabled
*/
public void setSuggestionsEnabled(boolean enabled) {
mSuggestionsEnabled = enabled;
@@ -9728,10 +9757,12 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
@Override
public void show() {
- mPasteTextView.setVisibility(canPaste() ? View.VISIBLE : View.GONE);
- mReplaceTextView.setVisibility(mSuggestionsEnabled ? View.VISIBLE : View.GONE);
+ boolean canPaste = canPaste();
+ boolean suggestionsEnabled = isSuggestionsEnabled();
+ mPasteTextView.setVisibility(canPaste ? View.VISIBLE : View.GONE);
+ mReplaceTextView.setVisibility(suggestionsEnabled ? View.VISIBLE : View.GONE);
- if (!canPaste() && !mSuggestionsEnabled) return;
+ if (!canPaste && !suggestionsEnabled) return;
super.show();
}