summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Android.mk2
-rw-r--r--core/java/android/bluetooth/BluetoothAdapter.java15
-rw-r--r--core/java/android/bluetooth/BluetoothDeviceProfileState.java8
-rw-r--r--core/java/android/bluetooth/IBluetooth.aidl1
-rw-r--r--core/java/android/os/StrictMode.java68
-rw-r--r--core/java/android/os/SystemProperties.java2
-rw-r--r--core/java/android/preference/PreferenceFrameLayout.java14
-rw-r--r--core/java/android/server/BluetoothService.java38
-rw-r--r--core/java/android/view/IWindowManager.aidl6
-rw-r--r--core/java/android/webkit/OverScrollGlow.java12
-rw-r--r--core/java/android/widget/AbsListView.java111
-rw-r--r--core/java/android/widget/EdgeGlow.java40
-rw-r--r--core/java/android/widget/HorizontalScrollView.java53
-rw-r--r--core/java/android/widget/ScrollView.java51
-rw-r--r--core/java/android/widget/TextView.java254
-rw-r--r--core/res/res/drawable-hdpi/ic_clear.pngbin0 -> 1945 bytes
-rw-r--r--core/res/res/drawable-hdpi/ic_clear_off.pngbin0 -> 1774 bytes
-rw-r--r--core/res/res/drawable-hdpi/ic_commit.pngbin0 -> 1438 bytes
-rw-r--r--core/res/res/drawable-hdpi/ic_go.pngbin0 -> 1415 bytes
-rw-r--r--core/res/res/drawable-hdpi/ic_search.pngbin0 -> 2558 bytes
-rw-r--r--core/res/res/drawable-hdpi/ic_voice_search.pngbin0 -> 2070 bytes
-rw-r--r--core/res/res/drawable-mdpi/ic_clear.pngbin0 -> 1869 bytes
-rw-r--r--core/res/res/drawable-mdpi/ic_clear_off.pngbin0 -> 1623 bytes
-rw-r--r--core/res/res/drawable-mdpi/ic_commit.pngbin0 -> 1468 bytes
-rw-r--r--core/res/res/drawable-mdpi/ic_go.pngbin0 -> 1436 bytes
-rw-r--r--core/res/res/drawable-mdpi/ic_search.pngbin0 -> 2445 bytes
-rw-r--r--core/res/res/drawable-mdpi/ic_voice_search.pngbin0 -> 1980 bytes
-rw-r--r--core/res/res/layout/search_view.xml59
-rwxr-xr-xcore/res/res/values/attrs.xml12
-rw-r--r--core/res/res/values/colors.xml4
-rw-r--r--core/res/res/values/styles.xml36
-rw-r--r--core/res/res/values/themes.xml8
-rw-r--r--docs/html/guide/topics/resources/layout-resource.jd10
-rw-r--r--docs/html/resources/articles/layout-tricks-reuse.jd18
-rw-r--r--drm/libdrmframework/plugins/widevine/Android.mk27
-rw-r--r--libs/rs/java/Balls/src/com/android/balls/BallsRS.java2
-rw-r--r--libs/rs/java/Balls/src/com/android/balls/ball_physics.rs15
-rwxr-xr-xmedia/java/android/media/videoeditor/MediaProperties.java3
-rw-r--r--media/libwvm/Android.mk10
-rw-r--r--packages/SystemUI/res/drawable-hdpi/ic_notification_open.pngbin0 -> 508 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/ic_notification_veto.pngbin0 -> 602 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/ic_sysbar_notification_dnd.pngbin0 -> 1224 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/ic_sysbar_notification_dnd_off.pngbin0 -> 1238 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/ic_sysbar_quicksettings.pngbin0 -> 1414 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/ic_sysbar_rotate_off_lanscape.pngbin0 -> 911 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/ic_sysbar_rotate_off_portrait.pngbin0 -> 871 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/ic_sysbar_shadow.9.pngbin0 -> 300 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/recent_overlay.pngbin0 -> 302563 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/recent_rez_border.pngbin0 -> 28494 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/sysbar_signalmini_100.pngbin0 -> 2472 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/ic_notification_veto.pngbin0 -> 551 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/ic_sysbar_notification_dnd.pngbin0 -> 853 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/ic_sysbar_notification_dnd_off.pngbin0 -> 850 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/ic_sysbar_rotate_off_lanscape.pngbin0 -> 700 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/ic_sysbar_rotate_off_portrait.pngbin0 -> 697 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/recent_overlay.png (renamed from packages/SystemUI/res/drawable/recent_overlay.png)bin162325 -> 162325 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/recent_rez_border.png (renamed from packages/SystemUI/res/drawable/recent_rez_border.png)bin21739 -> 21739 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/sysbar_signal_0.pngbin0 -> 2585 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/sysbar_signal_10.pngbin0 -> 5134 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/sysbar_signal_100.pngbin0 -> 10128 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/sysbar_signal_20.pngbin0 -> 5958 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/sysbar_signal_30.pngbin0 -> 6780 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/sysbar_signal_40.pngbin0 -> 7537 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/sysbar_signal_50.pngbin0 -> 8164 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/sysbar_signal_60.pngbin0 -> 8703 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/sysbar_signal_70.pngbin0 -> 9377 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/sysbar_signal_80.pngbin0 -> 9827 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/sysbar_signal_90.pngbin0 -> 10446 bytes
-rw-r--r--packages/SystemUI/res/drawable-xlarge-hdpi/app_icon.pngbin0 -> 7310 bytes
-rw-r--r--services/audioflinger/A2dpAudioInterface.cpp89
-rw-r--r--services/audioflinger/A2dpAudioInterface.h1
-rw-r--r--services/java/com/android/server/WindowManagerService.java4
72 files changed, 597 insertions, 376 deletions
diff --git a/Android.mk b/Android.mk
index 7a24663..4c135da 100644
--- a/Android.mk
+++ b/Android.mk
@@ -391,6 +391,8 @@ sample_dir := development/samples
# (see development/build/sdk.atree)
web_docs_sample_code_flags := \
-hdf android.hasSamples 1 \
+ -samplecode $(sample_dir)/AccessibilityService \
+ resources/samples/AccessibilityService "Accessibility Service" \
-samplecode $(sample_dir)/ApiDemos \
resources/samples/ApiDemos "API Demos" \
-samplecode $(sample_dir)/BackupRestore \
diff --git a/core/java/android/bluetooth/BluetoothAdapter.java b/core/java/android/bluetooth/BluetoothAdapter.java
index 556fb10..32df4e8 100644
--- a/core/java/android/bluetooth/BluetoothAdapter.java
+++ b/core/java/android/bluetooth/BluetoothAdapter.java
@@ -521,6 +521,21 @@ public final class BluetoothAdapter {
}
/**
+ * Get the UUIDs supported by the local Bluetooth adapter.
+ *
+ * <p>Requires {@link android.Manifest.permission#BLUETOOTH}
+ *
+ * @return the UUIDs supported by the local Bluetooth Adapter.
+ * @hide
+ */
+ public ParcelUuid[] getUuids() {
+ try {
+ return mService.getUuids();
+ } catch (RemoteException e) {Log.e(TAG, "", e);}
+ return null;
+ }
+
+ /**
* Set the friendly Bluetooth name of the local Bluetooth adapter.
* <p>This name is visible to remote Bluetooth devices.
* <p>Valid Bluetooth names are a maximum of 248 bytes using UTF-8
diff --git a/core/java/android/bluetooth/BluetoothDeviceProfileState.java b/core/java/android/bluetooth/BluetoothDeviceProfileState.java
index 138e7f2..3eadff9 100644
--- a/core/java/android/bluetooth/BluetoothDeviceProfileState.java
+++ b/core/java/android/bluetooth/BluetoothDeviceProfileState.java
@@ -301,10 +301,9 @@ public final class BluetoothDeviceProfileState extends HierarchicalStateMachine
if (isPhoneDocked(mDevice)) {
// Don't auto connect to docks.
break;
- } else if (mHeadsetService == null) {
- deferMessage(message);
} else {
- if (mHeadsetService.getPriority(mDevice) ==
+ if (mHeadsetService != null &&
+ mHeadsetService.getPriority(mDevice) ==
BluetoothHeadset.PRIORITY_AUTO_CONNECT &&
mHeadsetService.getDevicesMatchingConnectionStates(
new int[] {BluetoothProfile.STATE_CONNECTED,
@@ -1027,7 +1026,8 @@ public final class BluetoothDeviceProfileState extends HierarchicalStateMachine
// This is again against spec. HFP incoming connections should be made
// before A2DP, so we should not hit this case. But many devices
// don't follow this.
- if (mHeadsetService.getPriority(mDevice) == BluetoothProfile.PRIORITY_ON) {
+ if (mHeadsetService != null &&
+ mHeadsetService.getPriority(mDevice) == BluetoothProfile.PRIORITY_ON) {
Message msg = new Message();
msg.what = CONNECT_OTHER_PROFILES;
msg.arg1 = CONNECT_HFP_OUTGOING;
diff --git a/core/java/android/bluetooth/IBluetooth.aidl b/core/java/android/bluetooth/IBluetooth.aidl
index aefb3f2..f3e73cf 100644
--- a/core/java/android/bluetooth/IBluetooth.aidl
+++ b/core/java/android/bluetooth/IBluetooth.aidl
@@ -35,6 +35,7 @@ interface IBluetooth
String getAddress();
String getName();
boolean setName(in String name);
+ ParcelUuid[] getUuids();
int getScanMode();
boolean setScanMode(int mode, int duration);
diff --git a/core/java/android/os/StrictMode.java b/core/java/android/os/StrictMode.java
index 854428f..754d073 100644
--- a/core/java/android/os/StrictMode.java
+++ b/core/java/android/os/StrictMode.java
@@ -113,6 +113,13 @@ public final class StrictMode {
private static final boolean IS_USER_BUILD = "user".equals(Build.TYPE);
private static final boolean IS_ENG_BUILD = "eng".equals(Build.TYPE);
+ /**
+ * The boolean system property to control screen flashes on violations.
+ *
+ * @hide
+ */
+ public static final String VISUAL_PROPERTY = "persist.sys.strictmode.visual";
+
// Only log a duplicate stack trace to the logs every second.
private static final long MIN_LOG_INTERVAL_MS = 1000;
@@ -712,29 +719,66 @@ public final class StrictMode {
return new ThreadPolicy(oldPolicyMask);
}
+ // We don't want to flash the screen red in the system server
+ // process, nor do we want to modify all the call sites of
+ // conditionallyEnableDebugLogging() in the system server,
+ // so instead we use this to determine if we are the system server.
+ private static boolean amTheSystemServerProcess() {
+ // Fast path. Most apps don't have the system server's UID.
+ if (Process.myUid() != Process.SYSTEM_UID) {
+ return false;
+ }
+
+ // The settings app, though, has the system server's UID so
+ // look up our stack to see if we came from the system server.
+ Throwable stack = new Throwable();
+ stack.fillInStackTrace();
+ for (StackTraceElement ste : stack.getStackTrace()) {
+ String clsName = ste.getClassName();
+ if (clsName != null && clsName.startsWith("com.android.server.")) {
+ return true;
+ }
+ }
+ return false;
+ }
+
/**
* Enable DropBox logging for debug phone builds.
*
* @hide
*/
public static boolean conditionallyEnableDebugLogging() {
+ boolean doFlashes = !amTheSystemServerProcess() &&
+ SystemProperties.getBoolean(VISUAL_PROPERTY, IS_ENG_BUILD);
+
// For debug builds, log event loop stalls to dropbox for analysis.
// Similar logic also appears in ActivityThread.java for system apps.
- if (IS_USER_BUILD) {
+ if (IS_USER_BUILD && !doFlashes) {
setCloseGuardEnabled(false);
return false;
}
- StrictMode.setThreadPolicyMask(
- StrictMode.DETECT_DISK_WRITE |
- StrictMode.DETECT_DISK_READ |
- StrictMode.DETECT_NETWORK |
- StrictMode.PENALTY_DROPBOX |
- (IS_ENG_BUILD ? StrictMode.PENALTY_FLASH : 0)
- );
- sVmPolicyMask = StrictMode.DETECT_VM_CURSOR_LEAKS |
- StrictMode.DETECT_VM_CLOSABLE_LEAKS |
- StrictMode.PENALTY_DROPBOX;
- setCloseGuardEnabled(vmClosableObjectLeaksEnabled());
+
+ int threadPolicyMask = StrictMode.DETECT_DISK_WRITE |
+ StrictMode.DETECT_DISK_READ |
+ StrictMode.DETECT_NETWORK;
+
+ if (!IS_USER_BUILD) {
+ threadPolicyMask |= StrictMode.PENALTY_DROPBOX;
+ }
+ if (doFlashes) {
+ threadPolicyMask |= StrictMode.PENALTY_FLASH;
+ }
+
+ StrictMode.setThreadPolicyMask(threadPolicyMask);
+
+ if (IS_USER_BUILD) {
+ setCloseGuardEnabled(false);
+ } else {
+ sVmPolicyMask = StrictMode.DETECT_VM_CURSOR_LEAKS |
+ StrictMode.DETECT_VM_CLOSABLE_LEAKS |
+ StrictMode.PENALTY_DROPBOX;
+ setCloseGuardEnabled(vmClosableObjectLeaksEnabled());
+ }
return true;
}
diff --git a/core/java/android/os/SystemProperties.java b/core/java/android/os/SystemProperties.java
index 4a036ec..619bf8d 100644
--- a/core/java/android/os/SystemProperties.java
+++ b/core/java/android/os/SystemProperties.java
@@ -93,7 +93,7 @@ public class SystemProperties
* Get the value for the given key, returned as a boolean.
* Values 'n', 'no', '0', 'false' or 'off' are considered false.
* Values 'y', 'yes', '1', 'true' or 'on' are considered true.
- * (case insensitive).
+ * (case sensitive).
* If the key does not exist, or has any other value, then the default
* result is returned.
* @param key the key to lookup
diff --git a/core/java/android/preference/PreferenceFrameLayout.java b/core/java/android/preference/PreferenceFrameLayout.java
index 426abf0..481859e 100644
--- a/core/java/android/preference/PreferenceFrameLayout.java
+++ b/core/java/android/preference/PreferenceFrameLayout.java
@@ -45,12 +45,18 @@ public class PreferenceFrameLayout extends FrameLayout {
TypedArray a = context.obtainStyledAttributes(attrs,
com.android.internal.R.styleable.PreferenceFrameLayout, defStyle, 0);
- mTopPadding = (int) a.getDimension(
+ float density = context.getResources().getDisplayMetrics().density;
+ int defaultTopPadding = (int) (density * DEFAULT_TOP_PADDING + 0.5f);
+ int defaultBottomPadding = (int) (density * DEFAULT_BOTTOM_PADDING + 0.5f);
+
+ mTopPadding = a.getDimensionPixelSize(
com.android.internal.R.styleable.PreferenceFrameLayout_topPadding,
- DEFAULT_TOP_PADDING);
- mBottomPadding = (int) a.getDimension(
+ defaultTopPadding);
+ mBottomPadding = a.getDimensionPixelSize(
com.android.internal.R.styleable.PreferenceFrameLayout_bottomPadding,
- DEFAULT_BOTTOM_PADDING);
+ defaultBottomPadding);
+
+
a.recycle();
}
diff --git a/core/java/android/server/BluetoothService.java b/core/java/android/server/BluetoothService.java
index 01a6b94..398b5ae 100644
--- a/core/java/android/server/BluetoothService.java
+++ b/core/java/android/server/BluetoothService.java
@@ -541,14 +541,15 @@ public class BluetoothService extends IBluetooth.Stub {
mHandler.obtainMessage(MESSAGE_REGISTER_SDP_RECORDS, 3, -1), 500);
break;
case 3:
- Log.d(TAG, "Registering opush record");
- SystemService.start("opush");
+ Log.d(TAG, "Registering pbap record");
+ SystemService.start("pbap");
mHandler.sendMessageDelayed(
- mHandler.obtainMessage(MESSAGE_REGISTER_SDP_RECORDS, 4, -1), 500);
+ mHandler.obtainMessage(MESSAGE_REGISTER_SDP_RECORDS, 4, -1), 500);
+
break;
case 4:
- Log.d(TAG, "Registering pbap record");
- SystemService.start("pbap");
+ Log.d(TAG, "Registering opush record");
+ SystemService.start("opush");
break;
}
break;
@@ -630,8 +631,15 @@ public class BluetoothService extends IBluetooth.Stub {
initProfileState();
//Register SDP records.
- mHandler.sendMessageDelayed(
+ if (mContext.getResources().
+ getBoolean(com.android.internal.R.bool.config_voice_capable)) {
+ mHandler.sendMessageDelayed(
mHandler.obtainMessage(MESSAGE_REGISTER_SDP_RECORDS, 1, -1), 3000);
+ } else {
+ // Register only OPP.
+ mHandler.sendMessageDelayed(
+ mHandler.obtainMessage(MESSAGE_REGISTER_SDP_RECORDS, 4, -1), 3000);
+ }
setBluetoothTetheringNative(true, BluetoothPan.NAP_ROLE, BluetoothPan.NAP_BRIDGE);
@@ -1196,6 +1204,24 @@ public class BluetoothService extends IBluetooth.Stub {
return getProperty("Name");
}
+ public synchronized ParcelUuid[] getUuids() {
+ mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
+ String value = getProperty("UUIDs");
+ if (value == null) return null;
+
+ String[] uuidStrings = null;
+ // The UUIDs are stored as a "," separated string.
+ uuidStrings = value.split(",");
+ ParcelUuid[] uuids = new ParcelUuid[uuidStrings.length];
+
+ for (int i = 0; i < uuidStrings.length; i++) {
+ uuids[i] = ParcelUuid.fromString(uuidStrings[i]);
+ }
+ return uuids;
+
+ }
+
+
/**
* Returns the user-friendly name of a remote device. This value is
* returned from our local cache, which is updated when onPropertyChange
diff --git a/core/java/android/view/IWindowManager.aidl b/core/java/android/view/IWindowManager.aidl
index d964e2f..beda099 100644
--- a/core/java/android/view/IWindowManager.aidl
+++ b/core/java/android/view/IWindowManager.aidl
@@ -140,6 +140,12 @@ interface IWindowManager
// on screen)
void showStrictModeViolation(boolean on);
+ // Proxy to set the system property for whether the flashing
+ // should be enabled. The 'enabled' value is null or blank for
+ // the system default (differs per build variant) or any valid
+ // boolean string as parsed by SystemProperties.getBoolean().
+ void setStrictModeVisualIndicatorPreference(String enabled);
+
// These can only be called with the SET_ORIENTATION permission.
/**
* Change the current screen rotation, constants as per
diff --git a/core/java/android/webkit/OverScrollGlow.java b/core/java/android/webkit/OverScrollGlow.java
index 53600f6..af56a2f 100644
--- a/core/java/android/webkit/OverScrollGlow.java
+++ b/core/java/android/webkit/OverScrollGlow.java
@@ -17,6 +17,7 @@ package android.webkit;
import com.android.internal.R;
+import android.content.Context;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
@@ -40,13 +41,14 @@ public class OverScrollGlow {
public OverScrollGlow(WebView host) {
mHostView = host;
- final Resources res = host.getContext().getResources();
+ Context context = host.getContext();
+ final Resources res = context.getResources();
final Drawable edge = res.getDrawable(R.drawable.overscroll_edge);
final Drawable glow = res.getDrawable(R.drawable.overscroll_glow);
- mEdgeGlowTop = new EdgeGlow(edge, glow);
- mEdgeGlowBottom = new EdgeGlow(edge, glow);
- mEdgeGlowLeft = new EdgeGlow(edge, glow);
- mEdgeGlowRight = new EdgeGlow(edge, glow);
+ mEdgeGlowTop = new EdgeGlow(context, edge, glow);
+ mEdgeGlowBottom = new EdgeGlow(context, edge, glow);
+ mEdgeGlowLeft = new EdgeGlow(context, edge, glow);
+ mEdgeGlowRight = new EdgeGlow(context, edge, glow);
}
/**
diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java
index 423a788..4ff7ee8 100644
--- a/core/java/android/widget/AbsListView.java
+++ b/core/java/android/widget/AbsListView.java
@@ -132,7 +132,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
* Indicates the touch gesture is a scroll
*/
static final int TOUCH_MODE_SCROLL = 3;
-
+
/**
* Indicates the view is in the process of being flung
*/
@@ -385,7 +385,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
* Handles one frame of a fling
*/
private FlingRunnable mFlingRunnable;
-
+
/**
* Handles scrolling between positions within the list.
*/
@@ -456,7 +456,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
int mResurrectToPosition = INVALID_POSITION;
private ContextMenuInfo mContextMenuInfo = null;
-
+
/**
* Maximum distance to record overscroll
*/
@@ -550,19 +550,19 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
private int mMinimumVelocity;
private int mMaximumVelocity;
private float mVelocityScale = 1.0f;
-
+
final boolean[] mIsScrap = new boolean[1];
-
+
// True when the popup should be hidden because of a call to
// dispatchDisplayHint()
private boolean mPopupHidden;
-
+
/**
* ID of the active pointer. This is used to retain consistency during
* drags/flings if multiple pointers are used.
*/
private int mActivePointerId = INVALID_POINTER;
-
+
/**
* Sentinel value for no current active pointer.
* Used by {@link #mActivePointerId}.
@@ -726,7 +726,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
boolean smoothScrollbar = a.getBoolean(R.styleable.AbsListView_smoothScrollbar, true);
setSmoothScrollbarEnabled(smoothScrollbar);
-
+
final int adapterId = a.getResourceId(R.styleable.AbsListView_adapter, 0);
if (adapterId != 0) {
final Context c = context;
@@ -764,11 +764,12 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
public void setOverScrollMode(int mode) {
if (mode != OVER_SCROLL_NEVER) {
if (mEdgeGlowTop == null) {
- final Resources res = getContext().getResources();
+ Context context = getContext();
+ final Resources res = context.getResources();
final Drawable edge = res.getDrawable(R.drawable.overscroll_edge);
final Drawable glow = res.getDrawable(R.drawable.overscroll_glow);
- mEdgeGlowTop = new EdgeGlow(edge, glow);
- mEdgeGlowBottom = new EdgeGlow(edge, glow);
+ mEdgeGlowTop = new EdgeGlow(context, edge, glow);
+ mEdgeGlowBottom = new EdgeGlow(context, edge, glow);
}
} else {
mEdgeGlowTop = null;
@@ -1843,7 +1844,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
* @param position The position to display
* @param isScrap Array of at least 1 boolean, the first entry will become true if
* the returned view was taken from the scrap heap, false if otherwise.
- *
+ *
* @return A view displaying the data associated with the specified position
*/
View obtainView(int position, boolean[] isScrap) {
@@ -2166,7 +2167,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
treeObserver.addOnGlobalLayoutListener(this);
}
}
-
+
if (mAdapter != null && mDataSetObserver == null) {
mDataSetObserver = new AdapterDataSetObserver();
mAdapter.registerDataSetObserver(mDataSetObserver);
@@ -2962,7 +2963,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
mFlingRunnable = new FlingRunnable();
}
reportScrollStateChange(OnScrollListener.SCROLL_STATE_FLING);
-
+
mFlingRunnable.start(-initialVelocity);
} else {
mTouchMode = TOUCH_MODE_REST;
@@ -3015,7 +3016,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
mVelocityTracker.recycle();
mVelocityTracker = null;
}
-
+
mActivePointerId = INVALID_POINTER;
if (PROFILE_SCROLLING) {
@@ -3064,7 +3065,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
mVelocityTracker = null;
}
}
-
+
if (mEdgeGlowTop != null) {
mEdgeGlowTop.onRelease();
mEdgeGlowBottom.onRelease();
@@ -3072,7 +3073,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
mActivePointerId = INVALID_POINTER;
break;
}
-
+
case MotionEvent.ACTION_POINTER_UP: {
onSecondaryPointerUp(ev);
final int x = mMotionX;
@@ -3170,11 +3171,11 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
mMotionCorrection = 0;
return true;
}
-
+
final int x = (int) ev.getX();
final int y = (int) ev.getY();
mActivePointerId = ev.getPointerId(0);
-
+
int motionPosition = findMotionRow(y);
if (touchMode != TOUCH_MODE_FLING && motionPosition >= 0) {
// User clicked on an actual view (and was not stopping a fling).
@@ -3213,7 +3214,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
reportScrollStateChange(OnScrollListener.SCROLL_STATE_IDLE);
break;
}
-
+
case MotionEvent.ACTION_POINTER_UP: {
onSecondaryPointerUp(ev);
break;
@@ -3222,7 +3223,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
return false;
}
-
+
private void onSecondaryPointerUp(MotionEvent ev) {
final int pointerIndex = (ev.getAction() & MotionEvent.ACTION_POINTER_INDEX_MASK) >>
MotionEvent.ACTION_POINTER_INDEX_SHIFT;
@@ -3418,7 +3419,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
default:
endFling();
return;
-
+
case TOUCH_MODE_SCROLL:
if (mScroller.isFinished()) {
return;
@@ -3521,17 +3522,17 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
}
}
}
-
-
+
+
class PositionScroller implements Runnable {
private static final int SCROLL_DURATION = 400;
-
+
private static final int MOVE_DOWN_POS = 1;
private static final int MOVE_UP_POS = 2;
private static final int MOVE_DOWN_BOUND = 3;
private static final int MOVE_UP_BOUND = 4;
private static final int MOVE_OFFSET = 5;
-
+
private int mMode;
private int mTargetPos;
private int mBoundPos;
@@ -3540,17 +3541,17 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
private final int mExtraScroll;
private int mOffsetFromTop;
-
+
PositionScroller() {
mExtraScroll = ViewConfiguration.get(mContext).getScaledFadingEdgeLength();
}
-
+
void start(int position) {
final int firstPos = mFirstPosition;
final int lastPos = firstPos + getChildCount() - 1;
-
+
int viewTravelCount;
- if (position <= firstPos) {
+ if (position <= firstPos) {
viewTravelCount = firstPos - position + 1;
mMode = MOVE_UP_POS;
} else if (position >= lastPos) {
@@ -3560,7 +3561,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
// Already on screen, nothing to do
return;
}
-
+
if (viewTravelCount > 0) {
mScrollDuration = SCROLL_DURATION / viewTravelCount;
} else {
@@ -3569,19 +3570,19 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
mTargetPos = position;
mBoundPos = INVALID_POSITION;
mLastSeenPos = INVALID_POSITION;
-
+
post(this);
}
-
+
void start(int position, int boundPosition) {
if (boundPosition == INVALID_POSITION) {
start(position);
return;
}
-
+
final int firstPos = mFirstPosition;
final int lastPos = firstPos + getChildCount() - 1;
-
+
int viewTravelCount;
if (position <= firstPos) {
final int boundPosFromLast = lastPos - boundPosition;
@@ -3589,7 +3590,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
// Moving would shift our bound position off the screen. Abort.
return;
}
-
+
final int posTravel = firstPos - position + 1;
final int boundTravel = boundPosFromLast - 1;
if (boundTravel < posTravel) {
@@ -3619,7 +3620,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
// Already on screen, nothing to do
return;
}
-
+
if (viewTravelCount > 0) {
mScrollDuration = SCROLL_DURATION / viewTravelCount;
} else {
@@ -3628,7 +3629,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
mTargetPos = position;
mBoundPos = boundPosition;
mLastSeenPos = INVALID_POSITION;
-
+
post(this);
}
@@ -3679,12 +3680,12 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
final int listHeight = getHeight();
final int firstPos = mFirstPosition;
-
+
switch (mMode) {
case MOVE_DOWN_POS: {
final int lastViewIndex = getChildCount() - 1;
final int lastPos = firstPos + lastViewIndex;
-
+
if (lastViewIndex < 0) {
return;
}
@@ -3710,11 +3711,11 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
}
break;
}
-
+
case MOVE_DOWN_BOUND: {
final int nextViewIndex = 1;
final int childCount = getChildCount();
-
+
if (firstPos == mBoundPos || childCount <= nextViewIndex
|| firstPos + childCount >= mItemCount) {
return;
@@ -3739,13 +3740,13 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
post(this);
} else {
- if (nextViewTop > extraScroll) {
+ if (nextViewTop > extraScroll) {
smoothScrollBy(nextViewTop - extraScroll, mScrollDuration);
}
}
break;
}
-
+
case MOVE_UP_POS: {
if (firstPos == mLastSeenPos) {
// No new views, let things keep going.
@@ -3769,7 +3770,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
}
break;
}
-
+
case MOVE_UP_BOUND: {
final int lastViewIndex = getChildCount() - 2;
if (lastViewIndex < 0) {
@@ -3835,11 +3836,11 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
}
}
}
-
+
/**
* The amount of friction applied to flings. The default value
* is {@link ViewConfiguration#getScrollFriction}.
- *
+ *
* @return A scalar dimensionless value representing the coefficient of
* friction.
*/
@@ -3847,19 +3848,19 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
if (mFlingRunnable == null) {
mFlingRunnable = new FlingRunnable();
}
- mFlingRunnable.mScroller.setFriction(friction);
+ mFlingRunnable.mScroller.setFriction(friction);
}
/**
* Sets a scale factor for the fling velocity. The initial scale
* factor is 1.0.
- *
+ *
* @param scale The scale factor to multiply the velocity by.
*/
public void setVelocityScale(float scale) {
mVelocityScale = scale;
}
-
+
/**
* Smoothly scroll to the specified adapter position. The view will
* scroll such that the indicated position is displayed.
@@ -3913,7 +3914,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
* Smoothly scroll to the specified adapter position. The view will
* scroll such that the indicated position is displayed, but it will
* stop early if scrolling further would scroll boundPosition out of
- * view.
+ * view.
* @param position Scroll to this adapter position.
* @param boundPosition Do not scroll if it would move this adapter
* position out of view.
@@ -3924,7 +3925,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
}
mPositionScroller.start(position, boundPosition);
}
-
+
/**
* Smoothly scroll by distance pixels over duration milliseconds.
* @param distance Distance to scroll in pixels.
@@ -4145,7 +4146,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
if (down) {
mFirstPosition += count;
}
-
+
invalidate();
final int absIncrementalDeltaY = Math.abs(incrementalDeltaY);
@@ -4171,7 +4172,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
invokeOnItemScrollListener();
awakenScrollBars();
-
+
return false;
}
@@ -5289,7 +5290,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
mCurrentScrap = scrapViews[0];
mScrapViews = scrapViews;
}
-
+
public void markChildrenDirty() {
if (mViewTypeCount == 1) {
final ArrayList<View> scrap = mCurrentScrap;
diff --git a/core/java/android/widget/EdgeGlow.java b/core/java/android/widget/EdgeGlow.java
index 9b3a6e6..2a0e849 100644
--- a/core/java/android/widget/EdgeGlow.java
+++ b/core/java/android/widget/EdgeGlow.java
@@ -16,6 +16,7 @@
package android.widget;
+import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.view.animation.AnimationUtils;
@@ -44,7 +45,7 @@ public class EdgeGlow {
private static final float HELD_GLOW_ALPHA = 0.5f;
private static final float HELD_GLOW_SCALE_Y = 0.5f;
- private static final float MAX_GLOW_HEIGHT = 3.f;
+ private static final float MAX_GLOW_HEIGHT = 4.f;
private static final float PULL_GLOW_BEGIN = 1.f;
private static final float PULL_EDGE_BEGIN = 0.6f;
@@ -58,6 +59,8 @@ public class EdgeGlow {
private final Drawable mGlow;
private int mWidth;
private int mHeight;
+ private final int MIN_WIDTH = 300;
+ private final int mMinWidth;
private float mEdgeAlpha;
private float mEdgeScaleY;
@@ -86,12 +89,12 @@ public class EdgeGlow {
// How much dragging should effect the height of the edge image.
// Number determined by user testing.
- private static final int PULL_DISTANCE_EDGE_FACTOR = 5;
+ private static final int PULL_DISTANCE_EDGE_FACTOR = 7;
// How much dragging should effect the height of the glow image.
// Number determined by user testing.
- private static final int PULL_DISTANCE_GLOW_FACTOR = 5;
- private static final float PULL_DISTANCE_ALPHA_GLOW_FACTOR = 0.8f;
+ private static final int PULL_DISTANCE_GLOW_FACTOR = 7;
+ private static final float PULL_DISTANCE_ALPHA_GLOW_FACTOR = 1.1f;
private static final int VELOCITY_EDGE_FACTOR = 8;
private static final int VELOCITY_GLOW_FACTOR = 16;
@@ -100,10 +103,11 @@ public class EdgeGlow {
private float mPullDistance;
- public EdgeGlow(Drawable edge, Drawable glow) {
+ public EdgeGlow(Context context, Drawable edge, Drawable glow) {
mEdge = edge;
mGlow = glow;
+ mMinWidth = (int) (context.getResources().getDisplayMetrics().density * MIN_WIDTH + 0.5f);
mInterpolator = new DecelerateInterpolator();
}
@@ -251,17 +255,31 @@ public class EdgeGlow {
mGlow.setAlpha((int) (Math.max(0, Math.min(mGlowAlpha, 1)) * 255));
- // Center the glow inside the width of the container.
- int glowLeft = (mWidth - glowWidth)/2;
- mGlow.setBounds(glowLeft, 0, mWidth - glowLeft, (int) Math.min(
+ int glowBottom = (int) Math.min(
glowHeight * mGlowScaleY * glowHeight/ glowWidth * 0.6f,
- glowHeight * MAX_GLOW_HEIGHT));
+ glowHeight * MAX_GLOW_HEIGHT);
+ if (mWidth < mMinWidth) {
+ // Center the glow and clip it.
+ int glowLeft = (mWidth - glowWidth)/2;
+ mGlow.setBounds(glowLeft, 0, mWidth - glowLeft, glowBottom);
+ } else {
+ // Stretch the glow to fit.
+ mGlow.setBounds(0, 0, mWidth, glowBottom);
+ }
+
mGlow.draw(canvas);
mEdge.setAlpha((int) (Math.max(0, Math.min(mEdgeAlpha, 1)) * 255));
- int edgeLeft = (mWidth - edgeWidth)/2;
- mEdge.setBounds(edgeLeft, 0, mWidth - edgeLeft, (int) (edgeHeight * mEdgeScaleY));
+ int edgeBottom = (int) (edgeHeight * mEdgeScaleY);
+ if (mWidth < mMinWidth) {
+ // Center the edge and clip it.
+ int edgeLeft = (mWidth - edgeWidth)/2;
+ mEdge.setBounds(edgeLeft, 0, mWidth - edgeLeft, edgeBottom);
+ } else {
+ // Stretch the edge to fit.
+ mEdge.setBounds(0, 0, mWidth, edgeBottom);
+ }
mEdge.draw(canvas);
return mState != STATE_IDLE;
diff --git a/core/java/android/widget/HorizontalScrollView.java b/core/java/android/widget/HorizontalScrollView.java
index 9fc91da..c05e3ad 100644
--- a/core/java/android/widget/HorizontalScrollView.java
+++ b/core/java/android/widget/HorizontalScrollView.java
@@ -58,8 +58,8 @@ import java.util.List;
* within a larger container.
*
* <p>HorizontalScrollView only supports horizontal scrolling.
- *
- * @attr ref android.R.styleable#HorizontalScrollView_fillViewport
+ *
+ * @attr ref android.R.styleable#HorizontalScrollView_fillViewport
*/
public class HorizontalScrollView extends FrameLayout {
private static final int ANIMATED_SCROLL_GAP = ScrollView.ANIMATED_SCROLL_GAP;
@@ -125,7 +125,7 @@ public class HorizontalScrollView extends FrameLayout {
private int mTouchSlop;
private int mMinimumVelocity;
private int mMaximumVelocity;
-
+
private int mOverscrollDistance;
private int mOverflingDistance;
@@ -134,13 +134,13 @@ public class HorizontalScrollView extends FrameLayout {
* drags/flings if multiple pointers are used.
*/
private int mActivePointerId = INVALID_POINTER;
-
+
/**
* Sentinel value for no current active pointer.
* Used by {@link #mActivePointerId}.
*/
private static final int INVALID_POINTER = -1;
-
+
public HorizontalScrollView(Context context) {
this(context, null);
}
@@ -279,7 +279,7 @@ public class HorizontalScrollView extends FrameLayout {
*
* @param fillViewport True to stretch the content's width to the viewport's
* boundaries, false otherwise.
- *
+ *
* @attr ref android.R.styleable#HorizontalScrollView_fillViewport
*/
public void setFillViewport(boolean fillViewport) {
@@ -322,13 +322,13 @@ public class HorizontalScrollView extends FrameLayout {
int width = getMeasuredWidth();
if (child.getMeasuredWidth() < width) {
final FrameLayout.LayoutParams lp = (LayoutParams) child.getLayoutParams();
-
+
int childHeightMeasureSpec = getChildMeasureSpec(heightMeasureSpec, mPaddingTop
+ mPaddingBottom, lp.height);
width -= mPaddingLeft;
width -= mPaddingRight;
int childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY);
-
+
child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
}
}
@@ -400,7 +400,7 @@ public class HorizontalScrollView extends FrameLayout {
}
return false;
}
-
+
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
/*
@@ -453,7 +453,7 @@ public class HorizontalScrollView extends FrameLayout {
mIsBeingDragged = false;
break;
}
-
+
/*
* Remember location of down touch.
* ACTION_DOWN always refers to pointer index 0.
@@ -581,7 +581,7 @@ public class HorizontalScrollView extends FrameLayout {
}
}
}
-
+
mActivePointerId = INVALID_POINTER;
mIsBeingDragged = false;
@@ -618,7 +618,7 @@ public class HorizontalScrollView extends FrameLayout {
}
return true;
}
-
+
private void onSecondaryPointerUp(MotionEvent ev) {
final int pointerIndex = (ev.getAction() & MotionEvent.ACTION_POINTER_INDEX_MASK) >>
MotionEvent.ACTION_POINTER_INDEX_SHIFT;
@@ -635,7 +635,7 @@ public class HorizontalScrollView extends FrameLayout {
}
}
}
-
+
@Override
protected void onOverScrolled(int scrollX, int scrollY,
boolean clampedX, boolean clampedY) {
@@ -917,7 +917,7 @@ public class HorizontalScrollView extends FrameLayout {
if (direction == View.FOCUS_LEFT && getScrollX() < scrollDelta) {
scrollDelta = getScrollX();
} else if (direction == View.FOCUS_RIGHT && getChildCount() > 0) {
-
+
int daRight = getChildAt(0).getRight();
int screenRight = getScrollX() + getWidth();
@@ -1033,7 +1033,7 @@ public class HorizontalScrollView extends FrameLayout {
if (count == 0) {
return contentWidth;
}
-
+
int scrollRange = getChildAt(0).getRight();
final int scrollX = mScrollX;
final int overscrollRight = Math.max(0, scrollRange - contentWidth);
@@ -1045,7 +1045,7 @@ public class HorizontalScrollView extends FrameLayout {
return scrollRange;
}
-
+
@Override
protected int computeHorizontalScrollOffset() {
return Math.max(0, super.computeHorizontalScrollOffset());
@@ -1352,25 +1352,25 @@ public class HorizontalScrollView extends FrameLayout {
if (getChildCount() > 0) {
int width = getWidth() - mPaddingRight - mPaddingLeft;
int right = getChildAt(0).getWidth();
-
- mScroller.fling(mScrollX, mScrollY, velocityX, 0, 0,
+
+ mScroller.fling(mScrollX, mScrollY, velocityX, 0, 0,
Math.max(0, right - width), 0, 0, width/2, 0);
-
+
final boolean movingRight = velocityX > 0;
-
+
View newFocused = findFocusableViewInMyBounds(movingRight,
mScroller.getFinalX(), findFocus());
-
+
if (newFocused == null) {
newFocused = this;
}
-
+
if (newFocused != findFocus()
&& newFocused.requestFocus(movingRight ? View.FOCUS_RIGHT : View.FOCUS_LEFT)) {
mScrollViewMovedFocus = true;
mScrollViewMovedFocus = false;
}
-
+
invalidate();
}
}
@@ -1396,11 +1396,12 @@ public class HorizontalScrollView extends FrameLayout {
public void setOverScrollMode(int mode) {
if (mode != OVER_SCROLL_NEVER) {
if (mEdgeGlowLeft == null) {
- final Resources res = getContext().getResources();
+ Context context = getContext();
+ final Resources res = context.getResources();
final Drawable edge = res.getDrawable(R.drawable.overscroll_edge);
final Drawable glow = res.getDrawable(R.drawable.overscroll_glow);
- mEdgeGlowLeft = new EdgeGlow(edge, glow);
- mEdgeGlowRight = new EdgeGlow(edge, glow);
+ mEdgeGlowLeft = new EdgeGlow(context, edge, glow);
+ mEdgeGlowRight = new EdgeGlow(context, edge, glow);
}
} else {
mEdgeGlowLeft = null;
diff --git a/core/java/android/widget/ScrollView.java b/core/java/android/widget/ScrollView.java
index 900c9ec..9fa90dc 100644
--- a/core/java/android/widget/ScrollView.java
+++ b/core/java/android/widget/ScrollView.java
@@ -51,7 +51,7 @@ import java.util.List;
* takes care of its own scrolling, so does not require a ScrollView, but
* using the two together is possible to achieve the effect of a text view
* within a larger container.
- *
+ *
* <p>ScrollView only supports vertical scrolling.
*
* @attr ref android.R.styleable#ScrollView_fillViewport
@@ -120,7 +120,7 @@ public class ScrollView extends FrameLayout {
private int mTouchSlop;
private int mMinimumVelocity;
private int mMaximumVelocity;
-
+
private int mOverscrollDistance;
private int mOverflingDistance;
@@ -269,7 +269,7 @@ public class ScrollView extends FrameLayout {
* Indicates whether this ScrollView's content is stretched to fill the viewport.
*
* @return True if the content fills the viewport, false otherwise.
- *
+ *
* @attr ref android.R.styleable#ScrollView_fillViewport
*/
public boolean isFillViewport() {
@@ -282,7 +282,7 @@ public class ScrollView extends FrameLayout {
*
* @param fillViewport True to stretch the content's height to the viewport's
* boundaries, false otherwise.
- *
+ *
* @attr ref android.R.styleable#ScrollView_fillViewport
*/
public void setFillViewport(boolean fillViewport) {
@@ -325,14 +325,14 @@ public class ScrollView extends FrameLayout {
int height = getMeasuredHeight();
if (child.getMeasuredHeight() < height) {
final FrameLayout.LayoutParams lp = (LayoutParams) child.getLayoutParams();
-
+
int childWidthMeasureSpec = getChildMeasureSpec(widthMeasureSpec, mPaddingLeft
+ mPaddingRight, lp.width);
height -= mPaddingTop;
height -= mPaddingBottom;
int childHeightMeasureSpec =
MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY);
-
+
child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
}
}
@@ -521,7 +521,7 @@ public class ScrollView extends FrameLayout {
case MotionEvent.ACTION_DOWN: {
final float y = ev.getY();
mIsBeingDragged = true;
-
+
/*
* If being flinged and user touches, stop the fling. isFinished
* will be false if being flinged.
@@ -579,7 +579,7 @@ public class ScrollView extends FrameLayout {
}
}
break;
- case MotionEvent.ACTION_UP:
+ case MotionEvent.ACTION_UP:
if (mIsBeingDragged) {
final VelocityTracker velocityTracker = mVelocityTracker;
velocityTracker.computeCurrentVelocity(1000, mMaximumVelocity);
@@ -615,7 +615,7 @@ public class ScrollView extends FrameLayout {
}
return true;
}
-
+
private void onSecondaryPointerUp(MotionEvent ev) {
final int pointerIndex = (ev.getAction() & MotionEvent.ACTION_POINTER_INDEX_MASK) >>
MotionEvent.ACTION_POINTER_INDEX_SHIFT;
@@ -632,7 +632,7 @@ public class ScrollView extends FrameLayout {
}
}
}
-
+
@Override
protected void onOverScrolled(int scrollX, int scrollY,
boolean clampedX, boolean clampedY) {
@@ -919,9 +919,9 @@ public class ScrollView extends FrameLayout {
} else if (direction == View.FOCUS_DOWN) {
if (getChildCount() > 0) {
int daBottom = getChildAt(0).getBottom();
-
+
int screenBottom = getScrollY() + getHeight();
-
+
if (daBottom - screenBottom < maxJump) {
scrollDelta = daBottom - screenBottom;
}
@@ -1038,7 +1038,7 @@ public class ScrollView extends FrameLayout {
if (count == 0) {
return contentHeight;
}
-
+
int scrollRange = getChildAt(0).getBottom();
final int scrollY = mScrollY;
final int overscrollBottom = Math.max(0, scrollRange - contentHeight);
@@ -1289,7 +1289,7 @@ public class ScrollView extends FrameLayout {
}
return nextFocus.requestFocus(direction, previouslyFocusedRect);
- }
+ }
@Override
public boolean requestChildRectangleOnScreen(View child, Rect rectangle,
@@ -1325,7 +1325,7 @@ public class ScrollView extends FrameLayout {
protected void onLayout(boolean changed, int l, int t, int r, int b) {
super.onLayout(changed, l, t, r, b);
mIsLayoutDirty = false;
- // Give a child focus if it needs it
+ // Give a child focus if it needs it
if (mChildToScrollTo != null && isViewDescendantOf(mChildToScrollTo, this)) {
scrollToChild(mChildToScrollTo);
}
@@ -1352,7 +1352,7 @@ public class ScrollView extends FrameLayout {
int scrollDelta = computeScrollDeltaToGetChildRectOnScreen(mTempRect);
doScrollY(scrollDelta);
}
- }
+ }
/**
* Return true if child is an descendant of parent, (or equal to the parent).
@@ -1364,7 +1364,7 @@ public class ScrollView extends FrameLayout {
final ViewParent theParent = child.getParent();
return (theParent instanceof ViewGroup) && isViewDescendantOf((View) theParent, parent);
- }
+ }
/**
* Fling the scroll view
@@ -1377,18 +1377,18 @@ public class ScrollView extends FrameLayout {
if (getChildCount() > 0) {
int height = getHeight() - mPaddingBottom - mPaddingTop;
int bottom = getChildAt(0).getHeight();
-
- mScroller.fling(mScrollX, mScrollY, 0, velocityY, 0, 0, 0,
+
+ mScroller.fling(mScrollX, mScrollY, 0, velocityY, 0, 0, 0,
Math.max(0, bottom - height), 0, height/2);
-
+
final boolean movingDown = velocityY > 0;
-
+
View newFocused =
findFocusableViewInMyBounds(movingDown, mScroller.getFinalY(), findFocus());
if (newFocused == null) {
newFocused = this;
}
-
+
if (newFocused != findFocus()
&& newFocused.requestFocus(movingDown ? View.FOCUS_DOWN : View.FOCUS_UP)) {
mScrollViewMovedFocus = true;
@@ -1444,11 +1444,12 @@ public class ScrollView extends FrameLayout {
public void setOverScrollMode(int mode) {
if (mode != OVER_SCROLL_NEVER) {
if (mEdgeGlowTop == null) {
- final Resources res = getContext().getResources();
+ Context context = getContext();
+ final Resources res = context.getResources();
final Drawable edge = res.getDrawable(R.drawable.overscroll_edge);
final Drawable glow = res.getDrawable(R.drawable.overscroll_glow);
- mEdgeGlowTop = new EdgeGlow(edge, glow);
- mEdgeGlowBottom = new EdgeGlow(edge, glow);
+ mEdgeGlowTop = new EdgeGlow(context, edge, glow);
+ mEdgeGlowBottom = new EdgeGlow(context, edge, glow);
}
} else {
mEdgeGlowTop = null;
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 9f9fb18..6895863 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -313,6 +313,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
Drawable mSelectHandleRight;
Drawable mSelectHandleCenter;
+ private int mLastDownPositionX, mLastDownPositionY;
+
/*
* Kick-start the font cache for the zygote process (to pay the cost of
* initializing freetype for our default font only once).
@@ -3839,20 +3841,15 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
boolean changed = false;
- SelectionModifierCursorController selectionController = null;
- if (mSelectionModifierCursorController != null) {
- selectionController = (SelectionModifierCursorController)
- mSelectionModifierCursorController;
- }
-
-
if (mMovement != null) {
/* This code also provides auto-scrolling when a cursor is moved using a
* CursorController (insertion point or selection limits).
* For selection, ensure start or end is visible depending on controller's state.
*/
int curs = getSelectionEnd();
- if (selectionController != null && selectionController.isSelectionStartDragged()) {
+ // Do not create the controller if it is not already created.
+ if (mSelectionModifierCursorController != null &&
+ mSelectionModifierCursorController.isSelectionStartDragged()) {
curs = getSelectionStart();
}
@@ -3879,7 +3876,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
// - ExtractEditText does not call onFocus when it is displayed. Fixing this issue would
// allow to test for hasSelection in onFocusChanged, which would trigger a
// startTextSelectionMode here. TODO
- if (this instanceof ExtractEditText && selectionController != null && hasSelection()) {
+ if (this instanceof ExtractEditText && hasSelection() && hasSelectionController()) {
startSelectionActionMode();
}
@@ -3900,6 +3897,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
final ViewTreeObserver observer = getViewTreeObserver();
if (observer != null) {
+ // No need to create the controller.
+ // The get method will add the listener on controller creation.
if (mInsertionPointCursorController != null) {
observer.addOnTouchModeChangeListener(mInsertionPointCursorController);
}
@@ -3919,6 +3918,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
observer.removeOnPreDrawListener(this);
mPreDrawState = PREDRAW_NOT_REGISTERED;
}
+ // No need to create the controller, as getXXController would.
if (mInsertionPointCursorController != null) {
observer.removeOnTouchModeChangeListener(mInsertionPointCursorController);
}
@@ -4396,6 +4396,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
* @hide
*/
protected void updateCursorControllerPositions() {
+ // No need to create the controllers if they were not already
if (mInsertionPointCursorController != null &&
mInsertionPointCursorController.isShowing()) {
mInsertionPointCursorController.updatePosition();
@@ -6906,8 +6907,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
terminateSelectionActionMode();
}
+ // No need to create the controller
if (mSelectionModifierCursorController != null) {
- ((SelectionModifierCursorController) mSelectionModifierCursorController).resetTouchOffsets();
+ mSelectionModifierCursorController.resetTouchOffsets();
}
}
@@ -6921,9 +6923,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
}
private int getLastTapPosition() {
+ // No need to create the controller at that point, no last tap position saved
if (mSelectionModifierCursorController != null) {
- int lastTapPosition = ((SelectionModifierCursorController)
- mSelectionModifierCursorController).getMinTouchOffset();
+ int lastTapPosition = mSelectionModifierCursorController.getMinTouchOffset();
if (lastTapPosition >= 0) {
// Safety check, should not be possible.
if (lastTapPosition > mText.length()) {
@@ -7009,8 +7011,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
// Restore previous selection
Selection.setSelection((Spannable)mText, prevStart, prevEnd);
- if (hasSelectionController() && !getSelectionController().isShowing()) {
- // If the anchors aren't showing, revive them.
+ if (hasSelectionController()) {
+ // Revive the anchors.
getSelectionController().show();
}
return;
@@ -7065,6 +7067,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
}
if (action == MotionEvent.ACTION_DOWN) {
+ mLastDownPositionX = (int) event.getX();
+ mLastDownPositionY = (int) event.getY();
+
// Reset this state; it will be re-set if super.onTouchEvent
// causes focus to move to the view.
mTouchFocusSelected = false;
@@ -7102,6 +7107,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
if (mScrollX != oldScrollX || mScrollY != oldScrollY) {
// Hide insertion anchor while scrolling. Leave selection.
hideInsertionPointCursorController();
+ // No need to create the controller, since there is nothing to update.
if (mSelectionModifierCursorController != null &&
mSelectionModifierCursorController.isShowing()) {
mSelectionModifierCursorController.updatePosition();
@@ -7146,7 +7152,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|| windowParams.type > WindowManager.LayoutParams.LAST_SUB_WINDOW;
}
- // TODO Add an extra android:cursorController flag to disable the controller?
mInsertionControllerEnabled = windowSupportsHandles && isTextEditable() && mCursorVisible &&
mLayout != null && !mTextIsSelectable;
mSelectionControllerEnabled = windowSupportsHandles && textCanBeSelected() &&
@@ -7157,10 +7162,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
}
if (!mSelectionControllerEnabled) {
- // Stop selection mode if the controller becomes unavailable.
- if (mSelectionModifierCursorController != null) {
- stopSelectionActionMode();
- }
+ stopSelectionActionMode();
mSelectionModifierCursorController = null;
}
}
@@ -7580,11 +7582,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
minOffset = getSelectionStart();
maxOffset = getSelectionEnd();
} else {
- // selectionModifierCursorController is not null at that point
- SelectionModifierCursorController selectionModifierCursorController =
- ((SelectionModifierCursorController) mSelectionModifierCursorController);
- minOffset = selectionModifierCursorController.getMinTouchOffset();
- maxOffset = selectionModifierCursorController.getMaxTouchOffset();
+ // selectionModifierCursorController is guaranteed to exist at that point
+ SelectionModifierCursorController selectionController = getSelectionController();
+ minOffset = selectionController.getMinTouchOffset();
+ maxOffset = selectionController.getMaxTouchOffset();
}
int selectionStart, selectionEnd;
@@ -7771,7 +7772,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
// Two spaces at beginning of paste: remove one
final int originalLength = mText.length();
((Editable) mText).replace(min - 1, min, "");
- // Due to filters, there is no garantee that exactly one character was
+ // Due to filters, there is no guarantee that exactly one character was
// removed. Count instead.
final int delta = mText.length() - originalLength;
min += delta;
@@ -7838,19 +7839,26 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
return true;
}
- if (mSelectionActionMode != null) {
- if (touchPositionIsInSelection()) {
- // Start a drag
- final int start = getSelectionStart();
- final int end = getSelectionEnd();
- CharSequence selectedText = mTransformed.subSequence(start, end);
- ClipData data = ClipData.newPlainText(null, null, selectedText);
- startDrag(data, getTextThumbnailBuilder(selectedText), false);
- stopSelectionActionMode();
+ if (!isPositionOnText(mLastDownPositionX, mLastDownPositionY) && mInsertionControllerEnabled) {
+ final int offset = getOffset(mLastDownPositionX, mLastDownPositionY);
+ Selection.setSelection((Spannable)mText, offset);
+ if (canPaste()) {
+ getInsertionController().showWithPaste();
+ performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
} else {
- selectCurrentWord();
- getSelectionController().show();
+ getInsertionController().show();
}
+ mEatTouchRelease = true;
+ return true;
+ }
+
+ if (mSelectionActionMode != null && touchPositionIsInSelection()) {
+ final int start = getSelectionStart();
+ final int end = getSelectionEnd();
+ CharSequence selectedText = mTransformed.subSequence(start, end);
+ ClipData data = ClipData.newPlainText(null, null, selectedText);
+ startDrag(data, getTextThumbnailBuilder(selectedText), false);
+ stopSelectionActionMode();
performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
mEatTouchRelease = true;
return true;
@@ -7880,10 +7888,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
Selection.setSelection((Spannable) mText, selectionStart, selectionEnd);
}
- SelectionModifierCursorController selectionModifierCursorController =
- ((SelectionModifierCursorController) mSelectionModifierCursorController);
- int minOffset = selectionModifierCursorController.getMinTouchOffset();
- int maxOffset = selectionModifierCursorController.getMaxTouchOffset();
+ SelectionModifierCursorController selectionController = getSelectionController();
+ int minOffset = selectionController.getMinTouchOffset();
+ int maxOffset = selectionController.getMaxTouchOffset();
return ((minOffset >= selectionStart) && (maxOffset < selectionEnd));
}
@@ -7928,10 +7935,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
*/
private void terminateSelectionActionMode() {
stopSelectionActionMode();
+
+ // No need to create the controller, nothing to cancel in that case.
if (mSelectionModifierCursorController != null) {
- SelectionModifierCursorController selectionModifierCursorController =
- (SelectionModifierCursorController) mSelectionModifierCursorController;
- selectionModifierCursorController.cancelFadeOutAnimation();
+ mSelectionModifierCursorController.cancelFadeOutAnimation();
}
}
@@ -7973,7 +7980,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
- if (mSelectionModifierCursorController == null) {
+ if (!hasSelectionController()) {
Log.w(LOG_TAG, "TextView has no selection controller. Action mode cancelled.");
return false;
}
@@ -8029,7 +8036,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
styledAttributes.recycle();
if (atLeastOne) {
- mSelectionModifierCursorController.show();
+ getSelectionController().show();
return true;
} else {
return false;
@@ -8048,8 +8055,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
if (itemId == ID_SELECT_ALL) {
Selection.setSelection((Spannable) mText, 0, mText.length());
// Update controller positions after selection change.
- if (mSelectionModifierCursorController != null) {
- mSelectionModifierCursorController.show();
+ if (hasSelectionController()) {
+ getSelectionController().show();
}
return true;
}
@@ -8093,9 +8100,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
@Override
public void onDestroyActionMode(ActionMode mode) {
Selection.setSelection((Spannable) mText, getSelectionStart());
- if (mSelectionModifierCursorController != null) {
- mSelectionModifierCursorController.hide();
- }
+ hideSelectionModifierCursorController();
mSelectionActionMode = null;
}
}
@@ -8253,6 +8258,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
private int mLastParentY;
private int mContainerPositionX, mContainerPositionY;
private long mTouchTimer;
+ private boolean mHasPastePopupWindow = false;
private PastePopupMenu mPastePopupWindow;
public static final int LEFT = 0;
@@ -8305,7 +8311,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
mDrawable = mSelectHandleCenter;
handleWidth = mDrawable.getIntrinsicWidth();
mHotspotX = handleWidth / 2;
- mPastePopupWindow = new PastePopupMenu();
+ mHasPastePopupWindow = true;
break;
}
}
@@ -8473,9 +8479,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
mLastParentX = coords[0];
mLastParentY = coords[1];
mIsDragging = true;
- if (mPastePopupWindow != null) {
+ if (mHasPastePopupWindow) {
mTouchTimer = SystemClock.uptimeMillis();
- if (mPastePopupWindow.isShowing()) {
+ if (mPastePopupWindow != null && mPastePopupWindow.isShowing()) {
// Tapping on the handle again dismisses the displayed paste view,
mPastePopupWindow.hide();
// and makes sure the action up does not display the paste view.
@@ -8507,7 +8513,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
final int doubleTapSlop = viewConfiguration.getScaledDoubleTapSlop();
final int slopSquared = doubleTapSlop * doubleTapSlop;
if (distanceSquared < slopSquared) {
- mPastePopupWindow.show();
+ showPastePopupWindow();
}
}
}
@@ -8541,13 +8547,23 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
convertFromViewportToContentCoordinates(bounds);
moveTo(bounds.left, bounds.top);
}
+
+ void showPastePopupWindow() {
+ if (mHasPastePopupWindow) {
+ if (mPastePopupWindow == null) {
+ // Lazy initialisation: create when actually shown only.
+ mPastePopupWindow = new PastePopupMenu();
+ }
+ mPastePopupWindow.show();
+ }
+ }
}
private class InsertionPointCursorController implements CursorController {
private static final int DELAY_BEFORE_FADE_OUT = 4100;
- // The cursor controller image
- private final HandleView mHandle;
+ // The cursor controller image. Lazily created.
+ private HandleView mHandle;
private final Runnable mHider = new Runnable() {
public void run() {
@@ -8555,18 +8571,21 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
}
};
- InsertionPointCursorController() {
- mHandle = new HandleView(this, HandleView.CENTER);
- }
-
public void show() {
updatePosition();
- mHandle.show();
+ getHandle().show();
hideDelayed(DELAY_BEFORE_FADE_OUT);
}
+ void showWithPaste() {
+ show();
+ getHandle().showPastePopupWindow();
+ }
+
public void hide() {
- mHandle.hide();
+ if (mHandle != null) {
+ mHandle.hide();
+ }
TextView.this.removeCallbacks(mHider);
}
@@ -8576,7 +8595,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
}
public boolean isShowing() {
- return mHandle.isShowing();
+ return mHandle != null && mHandle.isShowing();
}
public void updatePosition(HandleView handle, int x, int y) {
@@ -8600,7 +8619,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
return;
}
- mHandle.positionAtCursor(offset, true);
+ // updatePosition is called only when isShowing. Handle has been created at this point.
+ getHandle().positionAtCursor(offset, true);
}
public boolean onTouchEvent(MotionEvent ev) {
@@ -8612,10 +8632,17 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
hide();
}
}
+
+ private HandleView getHandle() {
+ if (mHandle == null) {
+ mHandle = new HandleView(this, HandleView.CENTER);
+ }
+ return mHandle;
+ }
}
private class SelectionModifierCursorController implements CursorController {
- // The cursor controller images
+ // The cursor controller images, lazily created when shown.
private HandleView mStartHandle, mEndHandle;
// The offsets of that last touch down event. Remembered to start selection there.
private int mMinTouchOffset, mMaxTouchOffset;
@@ -8636,8 +8663,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
};
SelectionModifierCursorController() {
- mStartHandle = new HandleView(this, HandleView.LEFT);
- mEndHandle = new HandleView(this, HandleView.RIGHT);
resetTouchOffsets();
}
@@ -8646,17 +8671,23 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
return;
}
+ // Lazy object creation has to be done before updatePosition() is called.
+ if (mStartHandle == null) mStartHandle = new HandleView(this, HandleView.LEFT);
+ if (mEndHandle == null) mEndHandle = new HandleView(this, HandleView.RIGHT);
+
mIsShowing = true;
updatePosition();
+
mStartHandle.show();
mEndHandle.show();
+
hideInsertionPointCursorController();
hideDelayed(DELAY_BEFORE_FADE_OUT);
}
public void hide() {
- mStartHandle.hide();
- mEndHandle.hide();
+ if (mStartHandle != null) mStartHandle.hide();
+ if (mEndHandle != null) mEndHandle.hide();
mIsShowing = false;
removeCallbacks(mHider);
}
@@ -8723,6 +8754,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
return;
}
+ // The handles have been created since the controller isShowing().
mStartHandle.positionAtCursor(selectionStart, true);
mEndHandle.positionAtCursor(selectionEnd, true);
hideDelayed(DELAY_BEFORE_FADE_OUT);
@@ -8810,7 +8842,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
* @return true iff this controller is currently used to move the selection start.
*/
public boolean isSelectionStartDragged() {
- return mStartHandle.isDragging();
+ return mStartHandle != null && mStartHandle.isDragging();
}
public void onTouchModeChanged(boolean isInTouchMode) {
@@ -8821,12 +8853,14 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
}
private void hideInsertionPointCursorController() {
+ // No need to create the controller to hide it.
if (mInsertionPointCursorController != null) {
mInsertionPointCursorController.hide();
}
}
private void hideSelectionModifierCursorController() {
+ // No need to create the controller to hide it.
if (mSelectionModifierCursorController != null) {
mSelectionModifierCursorController.hide();
}
@@ -8837,15 +8871,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
hideSelectionModifierCursorController();
}
- private int getOffsetForHorizontal(int line, int x) {
- x -= getTotalPaddingLeft();
- // Clamp the position to inside of the view.
- x = Math.max(0, x);
- x = Math.min(getWidth() - getTotalPaddingRight() - 1, x);
- x += getScrollX();
- return getLayout().getOffsetForHorizontal(line, x);
- }
-
/**
* Get the offset character closest to the specified absolute position.
*
@@ -8858,15 +8883,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
*/
public int getOffset(int x, int y) {
if (getLayout() == null) return -1;
-
- y -= getTotalPaddingTop();
- // Clamp the position to inside of the view.
- y = Math.max(0, y);
- y = Math.min(getHeight() - getTotalPaddingBottom() - 1, y);
- y += getScrollY();
-
- final int line = getLayout().getLineForVertical(y);
- final int offset = getOffsetForHorizontal(line, x);
+ final int line = getLineAtCoordinate(y);
+ final int offset = getOffsetAtCoordinate(line, x);
return offset;
}
@@ -8874,14 +8892,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
final Layout layout = getLayout();
if (layout == null) return -1;
- y -= getTotalPaddingTop();
- // Clamp the position to inside of the view.
- y = Math.max(0, y);
- y = Math.min(getHeight() - getTotalPaddingBottom() - 1, y);
- y += getScrollY();
-
- int line = getLayout().getLineForVertical(y);
-
+ int line = getLineAtCoordinate(y);
final int previousLine = layout.getLineForOffset(previousOffset);
final int previousLineTop = layout.getLineTop(previousLine);
final int previousLineBottom = layout.getLineBottom(previousLine);
@@ -8894,21 +8905,58 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
line = previousLine;
}
- return getOffsetForHorizontal(line, x);
+ return getOffsetAtCoordinate(line, x);
+ }
+
+ private int convertToLocalHorizontalCoordinate(int x) {
+ x -= getTotalPaddingLeft();
+ // Clamp the position to inside of the view.
+ x = Math.max(0, x);
+ x = Math.min(getWidth() - getTotalPaddingRight() - 1, x);
+ x += getScrollX();
+ return x;
+ }
+
+ private int getLineAtCoordinate(int y) {
+ y -= getTotalPaddingTop();
+ // Clamp the position to inside of the view.
+ y = Math.max(0, y);
+ y = Math.min(getHeight() - getTotalPaddingBottom() - 1, y);
+ y += getScrollY();
+ return getLayout().getLineForVertical(y);
+ }
+
+ private int getOffsetAtCoordinate(int line, int x) {
+ x = convertToLocalHorizontalCoordinate(x);
+ return getLayout().getOffsetForHorizontal(line, x);
+ }
+
+ /** Returns true if the screen coordinates position (x,y) corresponds to a character displayed
+ * in the view. Returns false when the position is in the empty space of left/right of text.
+ */
+ private boolean isPositionOnText(int x, int y) {
+ if (getLayout() == null) return false;
+
+ final int line = getLineAtCoordinate(y);
+ x = convertToLocalHorizontalCoordinate(x);
+
+ if (x < getLayout().getLineLeft(line)) return false;
+ if (x > getLayout().getLineRight(line)) return false;
+ return true;
}
@Override
public boolean onDragEvent(DragEvent event) {
switch (event.getAction()) {
case DragEvent.ACTION_DRAG_STARTED:
- return mInsertionPointCursorController != null;
+ return hasInsertionController();
case DragEvent.ACTION_DRAG_ENTERED:
TextView.this.requestFocus();
return true;
case DragEvent.ACTION_DRAG_LOCATION: {
- final int offset = getOffset((int)event.getX(), (int)event.getY());
+ final int offset = getOffset((int) event.getX(), (int) event.getY());
Selection.setSelection((Spannable)mText, offset);
return true;
}
@@ -8951,7 +8999,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
return mSelectionControllerEnabled;
}
- CursorController getInsertionController() {
+ InsertionPointCursorController getInsertionController() {
if (!mInsertionControllerEnabled) {
return null;
}
@@ -8968,7 +9016,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
return mInsertionPointCursorController;
}
- CursorController getSelectionController() {
+ SelectionModifierCursorController getSelectionController() {
if (!mSelectionControllerEnabled) {
return null;
}
@@ -9027,8 +9075,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
private boolean mCursorVisible = true;
// Cursor Controllers.
- private CursorController mInsertionPointCursorController;
- private CursorController mSelectionModifierCursorController;
+ private InsertionPointCursorController mInsertionPointCursorController;
+ private SelectionModifierCursorController mSelectionModifierCursorController;
private ActionMode mSelectionActionMode;
private boolean mInsertionControllerEnabled;
private boolean mSelectionControllerEnabled;
diff --git a/core/res/res/drawable-hdpi/ic_clear.png b/core/res/res/drawable-hdpi/ic_clear.png
new file mode 100644
index 0000000..33ad8d4
--- /dev/null
+++ b/core/res/res/drawable-hdpi/ic_clear.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/ic_clear_off.png b/core/res/res/drawable-hdpi/ic_clear_off.png
new file mode 100644
index 0000000..d97c342
--- /dev/null
+++ b/core/res/res/drawable-hdpi/ic_clear_off.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/ic_commit.png b/core/res/res/drawable-hdpi/ic_commit.png
new file mode 100644
index 0000000..404051c
--- /dev/null
+++ b/core/res/res/drawable-hdpi/ic_commit.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/ic_go.png b/core/res/res/drawable-hdpi/ic_go.png
new file mode 100644
index 0000000..97b825e
--- /dev/null
+++ b/core/res/res/drawable-hdpi/ic_go.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/ic_search.png b/core/res/res/drawable-hdpi/ic_search.png
new file mode 100644
index 0000000..bf8bd66
--- /dev/null
+++ b/core/res/res/drawable-hdpi/ic_search.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/ic_voice_search.png b/core/res/res/drawable-hdpi/ic_voice_search.png
new file mode 100644
index 0000000..66d14ae
--- /dev/null
+++ b/core/res/res/drawable-hdpi/ic_voice_search.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/ic_clear.png b/core/res/res/drawable-mdpi/ic_clear.png
new file mode 100644
index 0000000..86944a8
--- /dev/null
+++ b/core/res/res/drawable-mdpi/ic_clear.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/ic_clear_off.png b/core/res/res/drawable-mdpi/ic_clear_off.png
new file mode 100644
index 0000000..b9c3b44
--- /dev/null
+++ b/core/res/res/drawable-mdpi/ic_clear_off.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/ic_commit.png b/core/res/res/drawable-mdpi/ic_commit.png
new file mode 100644
index 0000000..49d7ec8
--- /dev/null
+++ b/core/res/res/drawable-mdpi/ic_commit.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/ic_go.png b/core/res/res/drawable-mdpi/ic_go.png
new file mode 100644
index 0000000..2340648
--- /dev/null
+++ b/core/res/res/drawable-mdpi/ic_go.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/ic_search.png b/core/res/res/drawable-mdpi/ic_search.png
new file mode 100644
index 0000000..d92071b
--- /dev/null
+++ b/core/res/res/drawable-mdpi/ic_search.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/ic_voice_search.png b/core/res/res/drawable-mdpi/ic_voice_search.png
new file mode 100644
index 0000000..a2fe874
--- /dev/null
+++ b/core/res/res/drawable-mdpi/ic_voice_search.png
Binary files differ
diff --git a/core/res/res/layout/search_view.xml b/core/res/res/layout/search_view.xml
index 0fd9a77..eb0bb11 100644
--- a/core/res/res/layout/search_view.xml
+++ b/core/res/res/layout/search_view.xml
@@ -43,7 +43,8 @@
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="center_vertical"
- android:src="@android:drawable/ic_btn_search"
+ android:background="?android:attr/selectableItemBackground"
+ android:src="@android:drawable/ic_search"
/>
<LinearLayout
@@ -56,6 +57,7 @@
<!-- Inner layout contains the app icon, button(s) and EditText -->
<LinearLayout
+ android:id="@+id/search_plate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
@@ -65,16 +67,16 @@
<ImageView
android:id="@+id/search_app_icon"
- android:layout_height="24dip"
- android:layout_width="24dip"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
android:layout_marginRight="7dip"
- android:layout_gravity="bottom"
- android:src="@android:drawable/ic_btn_search"
+ android:layout_gravity="center_vertical"
+ android:src="?android:attr/searchViewSearchIcon"
/>
<AutoCompleteTextView
android:id="@+id/search_src_text"
- android:layout_height="wrap_content"
+ android:layout_height="36dip"
android:layout_width="0dp"
android:layout_weight="1"
android:minWidth="100dp"
@@ -88,43 +90,46 @@
android:inputType="text|textAutoComplete"
android:imeOptions="actionSearch"
android:dropDownHeight="wrap_content"
- android:dropDownAnchor="@id/search_edit_frame"
+ android:dropDownAnchor="@id/search_plate"
android:dropDownVerticalOffset="0dip"
android:dropDownHorizontalOffset="0dip"
- android:popupBackground="?android:attr/searchDropdownBackground"
/>
- <!-- TODO: Use the generic dialog close drawable -->
<ImageView
android:id="@+id/search_close_btn"
- android:layout_width="24dp"
- android:layout_height="24dp"
- android:layout_gravity="bottom"
- android:src="@android:drawable/btn_close"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:paddingLeft="4dip"
+ android:paddingRight="4dip"
+ android:layout_gravity="center_vertical"
+ android:background="?android:attr/selectableItemBackground"
+ android:src="?android:attr/searchViewCloseIcon"
/>
</LinearLayout>
- <ImageView
- android:id="@+id/search_go_btn"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="bottom"
- android:layout_marginLeft="4dip"
- android:layout_marginRight="4dip"
- android:src="@android:drawable/ic_btn_find_next"
- />
</LinearLayout>
- <ImageButton
+ <ImageView
+ android:id="@+id/search_go_btn"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:layout_gravity="center_vertical"
+ android:paddingLeft="4dip"
+ android:paddingRight="4dip"
+ android:background="?android:attr/selectableItemBackground"
+ android:src="?android:attr/searchViewGoIcon"
+ />
+
+ <ImageView
android:id="@+id/search_voice_btn"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
- android:layout_marginLeft="4dip"
- android:layout_marginRight="4dip"
- android:src="@android:drawable/ic_btn_speak_now"
- android:background="@android:color/transparent"
+ android:paddingLeft="4dip"
+ android:paddingRight="4dip"
+ android:src="?android:attr/searchViewVoiceIcon"
+ android:background="?android:attr/selectableItemBackground"
android:visibility="gone"
/>
</LinearLayout>
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index 3f81a89..eacd14e 100755
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -605,8 +605,20 @@
<!-- Background drawable for standalone items that need focus/pressed states. -->
<attr name="selectableItemBackground" format="reference" />
+ <!-- ============================ -->
+ <!-- SearchView styles and assets -->
+ <!-- ============================ -->
+ <eat-comment />
<!-- SearchView dropdown background -->
<attr name="searchDropdownBackground" format="reference" />
+ <!-- SearchView close button icon -->
+ <attr name="searchViewCloseIcon" format="reference" />
+ <!-- SearchView Go button icon -->
+ <attr name="searchViewGoIcon" format="reference" />
+ <!-- SearchView Search icon -->
+ <attr name="searchViewSearchIcon" format="reference" />
+ <!-- SearchView Voice button icon -->
+ <attr name="searchViewVoiceIcon" format="reference" />
<!-- Specifies a drawable to use for the 'home as up' indicator. -->
<attr name="homeAsUpIndicator" format="reference" />
diff --git a/core/res/res/values/colors.xml b/core/res/res/values/colors.xml
index 21b810e..d64fb74 100644
--- a/core/res/res/values/colors.xml
+++ b/core/res/res/values/colors.xml
@@ -110,8 +110,8 @@
<color name="background_holo_light">#fff3f3f3</color>
<color name="bright_foreground_holo_dark">@android:color/background_holo_light</color>
<color name="bright_foreground_holo_light">@android:color/background_holo_dark</color>
- <color name="bright_foreground_disabled_holo_dark">#80ffffff</color>
- <color name="bright_foreground_disabled_holo_light">#80000000</color>
+ <color name="bright_foreground_disabled_holo_dark">#ff4c4c4c</color>
+ <color name="bright_foreground_disabled_holo_light">#ffb2b2b2</color>
<color name="bright_foreground_inverse_holo_dark">@android:color/bright_foreground_holo_light</color>
<color name="bright_foreground_inverse_holo_light">@android:color/bright_foreground_holo_dark</color>
<color name="dim_foreground_holo_dark">#bebebe</color>
diff --git a/core/res/res/values/styles.xml b/core/res/res/values/styles.xml
index 6985de6..2754e73 100644
--- a/core/res/res/values/styles.xml
+++ b/core/res/res/values/styles.xml
@@ -779,23 +779,22 @@
<item name="android:textColor">@android:color/sliding_tab_text_color_active</item>
<item name="android:textSize">28sp</item>
</style>
-
- <!-- @hide -->
+ <!-- @hide -->
<style name="TextAppearance.SearchResult">
<item name="android:textStyle">normal</item>
<item name="android:textColor">?textColorPrimaryInverse</item>
<item name="android:textColorHint">?textColorHintInverse</item>
</style>
-
- <!-- @hide -->
+
+ <!-- @hide -->
<style name="TextAppearance.SearchResult.Title">
- <item name="android:textSize">16sp</item>
+ <item name="android:textSize">18sp</item>
</style>
-
- <!-- @hide -->
+
+ <!-- @hide -->
<style name="TextAppearance.SearchResult.Subtitle">
- <item name="android:textSize">13sp</item>
+ <item name="android:textSize">14sp</item>
<item name="android:textColor">?textColorSecondaryInverse</item>
</style>
@@ -1061,17 +1060,17 @@
<style name="TextAppearance.Holo.SearchResult">
<item name="android:textStyle">normal</item>
- <item name="android:textColor">?textColorPrimaryInverse</item>
- <item name="android:textColorHint">?textColorHintInverse</item>
+ <item name="android:textColor">?textColorPrimary</item>
+ <item name="android:textColorHint">?textColorHint</item>
</style>
<style name="TextAppearance.Holo.SearchResult.Title">
- <item name="android:textSize">16sp</item>
+ <item name="android:textSize">18sp</item>
</style>
<style name="TextAppearance.Holo.SearchResult.Subtitle">
- <item name="android:textSize">13sp</item>
- <item name="android:textColor">?textColorSecondaryInverse</item>
+ <item name="android:textSize">14sp</item>
+ <item name="android:textColor">?textColorSecondary</item>
</style>
<style name="TextAppearance.Holo.Widget" parent="TextAppearance.Widget">
@@ -1203,14 +1202,17 @@
</style>
<style name="TextAppearance.Holo.Light.SearchResult" parent="TextAppearance.Holo.SearchResult">
- <item name="android:textColor">?textColorPrimary</item>
- <item name="android:textColorHint">?textColorHint</item>
+ <item name="android:textColor">?textColorPrimary</item>
+ <item name="android:textColorHint">?textColorHint</item>
</style>
<style name="TextAppearance.Holo.Light.SearchResult.Title">
+ <item name="android:textSize">18sp</item>
</style>
<style name="TextAppearance.Holo.Light.SearchResult.Subtitle">
+ <item name="android:textSize">14sp</item>
+ <item name="android:textColor">?textColorSecondary</item>
</style>
<style name="TextAppearance.Holo.Light.Widget" parent="TextAppearance.Widget">
@@ -1320,6 +1322,8 @@
</style>
<style name="Widget.Holo.AutoCompleteTextView" parent="Widget.AutoCompleteTextView">
+ <item name="android:dropDownSelector">@android:drawable/list_selector_holo_dark</item>
+ <item name="android:popupBackground">@android:drawable/menu_dropdown_panel_holo_dark</item>
</style>
<style name="Widget.Holo.CompoundButton.CheckBox" parent="Widget.CompoundButton.CheckBox">
@@ -1620,6 +1624,8 @@
</style>
<style name="Widget.Holo.Light.AutoCompleteTextView" parent="Widget.AutoCompleteTextView">
+ <item name="android:dropDownSelector">@android:drawable/list_selector_holo_light</item>
+ <item name="android:popupBackground">@android:drawable/menu_dropdown_panel_holo_light</item>
</style>
<style name="Widget.Holo.Light.CompoundButton.CheckBox" parent="Widget.CompoundButton.CheckBox">
diff --git a/core/res/res/values/themes.xml b/core/res/res/values/themes.xml
index 1ef99d0..0eec0df 100644
--- a/core/res/res/values/themes.xml
+++ b/core/res/res/values/themes.xml
@@ -261,7 +261,11 @@
<item name="buttonGroupStyle">@android:style/Widget.ButtonGroup</item>
<!-- SearchView attributes -->
- <item name="searchDropdownBackground">@android:drawable/search_dropdown_dark</item>
+ <item name="searchDropdownBackground">@android:drawable/spinner_dropdown_background</item>
+ <item name="searchViewCloseIcon">@android:drawable/ic_clear</item>
+ <item name="searchViewSearchIcon">@android:drawable/ic_search</item>
+ <item name="searchViewGoIcon">@android:drawable/ic_go</item>
+ <item name="searchViewVoiceIcon">@android:drawable/ic_voice_search</item>
<!-- PreferenceFrameLayout attributes -->
<item name="preferenceFrameLayoutStyle">@android:style/Widget.PreferenceFrameLayout</item>
@@ -1028,7 +1032,7 @@
<!-- Widget styles -->
<item name="absListViewStyle">@android:style/Widget.Holo.AbsListView</item>
- <item name="autoCompleteTextViewStyle">@android:style/Widget.Holo.AutoCompleteTextView</item>
+ <item name="autoCompleteTextViewStyle">@android:style/Widget.Holo.Light.AutoCompleteTextView</item>
<item name="checkboxStyle">@android:style/Widget.Holo.CompoundButton.CheckBox</item>
<item name="dropDownListViewStyle">@android:style/Widget.Holo.ListView.DropDown</item>
<item name="editTextStyle">@android:style/Widget.Holo.EditText</item>
diff --git a/docs/html/guide/topics/resources/layout-resource.jd b/docs/html/guide/topics/resources/layout-resource.jd
index 111851c..36369d3 100644
--- a/docs/html/guide/topics/resources/layout-resource.jd
+++ b/docs/html/guide/topics/resources/layout-resource.jd
@@ -149,17 +149,23 @@ resource.</dd>
</dd>
<dt><code>android:layout_height</code></dt>
<dd><em>Dimension or keyword</em>. Overrides the height given to the root view in the
-included layout.
+included layout. Only effective if <code>android:layout_width</code> is also declared.
</dd>
<dt><code>android:layout_width</code></dt>
<dd><em>Dimension or keyword</em>. Overrides the width given to the root view in the
-included layout.
+included layout. Only effective if <code>android:layout_height</code> is also declared.
</dd>
</dl>
<p>You can include any other layout attributes in the <code>&lt;include&gt;</code> that are
supported by the root element in the included layout and they will override those defined in the
root element.</p>
+ <p class="caution"><strong>Caution:</strong> If you want to override the layout dimensions,
+you must override both <code>android:layout_height</code> and
+<code>android:layout_width</code>&mdash;you cannot override only the height or only the width.
+If you override only one, it will not take effect. (Other layout properties, such as weight,
+are still inherited from the source layout.)</p>
+
<p>Another way to include a layout is to use {@link android.view.ViewStub}. It is a lightweight
View that consumes no layout space until you explicitly inflate it, at which point, it includes a
layout file defined by its {@code android:layout} attribute. For more information about using {@link
diff --git a/docs/html/resources/articles/layout-tricks-reuse.jd b/docs/html/resources/articles/layout-tricks-reuse.jd
index 072ba89..396e212 100644
--- a/docs/html/resources/articles/layout-tricks-reuse.jd
+++ b/docs/html/resources/articles/layout-tricks-reuse.jd
@@ -53,12 +53,24 @@ attributes of the included layout. The above example shows that you can use
layout; it will also override the id of the included layout if one is defined.
Similarly, you can override all the layout parameters. This means that any
<code>android:layout_*</code> attribute can be used with the <code>&lt;include
-/&gt;</code> tag. Here is an example:</p>
+/&gt;</code> tag. Here is an example in
+which the same layout is included twice, but only the first one overrides the layout properties:</p>
-<pre class="prettyprint">&lt;include android:layout_width="fill_parent" layout="@layout/image_holder" /&gt;
-&lt;include android:layout_width="256dip" layout="@layout/image_holder" /&gt;
+<pre>
+&lt;!-- override the layout height and width --&gt;
+&lt;include layout="@layout/image_holder"
+ android:layout_height="fill_parent"
+ android:layout_width="fill_parent" /&gt;
+&lt;!-- do not override layout dimensions; inherit them from image_holder --&gt;
+&lt;include layout="@layout/image_holder" /&gt;
</pre>
+<p class="caution"><strong>Caution:</strong> If you want to override the layout dimensions,
+you must override both <code>android:layout_height</code> and
+<code>android:layout_width</code>&mdash;you cannot override only the height or only the width.
+If you override only one, it will not take effect. (Other layout properties, such as weight,
+are still inherited from the source layout.)</p>
+
<p>This tag is particularly useful when you need to customize only part of your
UI depending on the device's configuration. For instance, the main layout of
your activity can be placed in the <code>layout/</code> directory and can
diff --git a/drm/libdrmframework/plugins/widevine/Android.mk b/drm/libdrmframework/plugins/widevine/Android.mk
deleted file mode 100644
index 2c388da..0000000
--- a/drm/libdrmframework/plugins/widevine/Android.mk
+++ /dev/null
@@ -1,27 +0,0 @@
-#
-# Copyright (C) 2010 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := libdrmwvmplugin
-
-LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/drm/plugins/native
-
-LOCAL_PRELINK_MODULE := false
-
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/libs/rs/java/Balls/src/com/android/balls/BallsRS.java b/libs/rs/java/Balls/src/com/android/balls/BallsRS.java
index 76c23b7..42eaede 100644
--- a/libs/rs/java/Balls/src/com/android/balls/BallsRS.java
+++ b/libs/rs/java/Balls/src/com/android/balls/BallsRS.java
@@ -21,7 +21,7 @@ import android.renderscript.*;
import android.util.Log;
public class BallsRS {
- public static final int PART_COUNT = 800;
+ public static final int PART_COUNT = 1000;
public BallsRS() {
}
diff --git a/libs/rs/java/Balls/src/com/android/balls/ball_physics.rs b/libs/rs/java/Balls/src/com/android/balls/ball_physics.rs
index 96c39b1..47eaf1b 100644
--- a/libs/rs/java/Balls/src/com/android/balls/ball_physics.rs
+++ b/libs/rs/java/Balls/src/com/android/balls/ball_physics.rs
@@ -41,7 +41,20 @@ void root(const Ball_t *ballIn, Ball_t *ballOut, const BallControl_t *ctl, uint3
fv -= (vec / (len * len * len)) * 20000.f;
} else {
if (len2 < 0.1) {
- continue;
+ if (xin == x) {
+ continue;
+ }
+ ballOut->delta = 0.f;
+ ballOut->position = ballIn->position;
+ if (xin > x) {
+ ballOut->position.x += 1.f;
+ } else {
+ ballOut->position.x -= 1.f;
+ }
+ ballOut->color.rgb = 1.f;
+ ballOut->arcID = -1;
+ ballOut->arcStr = 0;
+ return;
}
// Collision
float2 axis = normalize(vec);
diff --git a/media/java/android/media/videoeditor/MediaProperties.java b/media/java/android/media/videoeditor/MediaProperties.java
index 34088fc..0bb83eb 100755
--- a/media/java/android/media/videoeditor/MediaProperties.java
+++ b/media/java/android/media/videoeditor/MediaProperties.java
@@ -95,6 +95,9 @@ public class MediaProperties {
public static final int BITRATE_384K = 384000;
public static final int BITRATE_512K = 512000;
public static final int BITRATE_800K = 800000;
+ public static final int BITRATE_2M = 2000000;
+ public static final int BITRATE_5M = 5000000;
+ public static final int BITRATE_8M = 8000000;
// The array of supported bitrates
private static final int[] SUPPORTED_BITRATES = new int[] {
diff --git a/media/libwvm/Android.mk b/media/libwvm/Android.mk
deleted file mode 100644
index 7c75c0f..0000000
--- a/media/libwvm/Android.mk
+++ /dev/null
@@ -1,10 +0,0 @@
-# create an empty mk for libwvm
-# for integration purpose
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := libwvm
-
-LOCAL_MODULE_TAGS := optional
-include $(BUILD_SHARED_LIBRARY)
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_notification_open.png b/packages/SystemUI/res/drawable-hdpi/ic_notification_open.png
new file mode 100644
index 0000000..d083396
--- /dev/null
+++ b/packages/SystemUI/res/drawable-hdpi/ic_notification_open.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_notification_veto.png b/packages/SystemUI/res/drawable-hdpi/ic_notification_veto.png
new file mode 100644
index 0000000..395604f
--- /dev/null
+++ b/packages/SystemUI/res/drawable-hdpi/ic_notification_veto.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_notification_dnd.png b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_notification_dnd.png
new file mode 100644
index 0000000..51b5809
--- /dev/null
+++ b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_notification_dnd.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_notification_dnd_off.png b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_notification_dnd_off.png
new file mode 100644
index 0000000..37ef7e1
--- /dev/null
+++ b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_notification_dnd_off.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_quicksettings.png b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_quicksettings.png
new file mode 100644
index 0000000..d9b4eca
--- /dev/null
+++ b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_quicksettings.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_rotate_off_lanscape.png b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_rotate_off_lanscape.png
new file mode 100644
index 0000000..c091489
--- /dev/null
+++ b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_rotate_off_lanscape.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_rotate_off_portrait.png b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_rotate_off_portrait.png
new file mode 100644
index 0000000..73a9897
--- /dev/null
+++ b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_rotate_off_portrait.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_shadow.9.png b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_shadow.9.png
new file mode 100644
index 0000000..7cb2643
--- /dev/null
+++ b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_shadow.9.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/recent_overlay.png b/packages/SystemUI/res/drawable-hdpi/recent_overlay.png
new file mode 100644
index 0000000..fcf4417
--- /dev/null
+++ b/packages/SystemUI/res/drawable-hdpi/recent_overlay.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/recent_rez_border.png b/packages/SystemUI/res/drawable-hdpi/recent_rez_border.png
new file mode 100644
index 0000000..af36ac7
--- /dev/null
+++ b/packages/SystemUI/res/drawable-hdpi/recent_rez_border.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/sysbar_signalmini_100.png b/packages/SystemUI/res/drawable-hdpi/sysbar_signalmini_100.png
new file mode 100644
index 0000000..d89f889
--- /dev/null
+++ b/packages/SystemUI/res/drawable-hdpi/sysbar_signalmini_100.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_notification_veto.png b/packages/SystemUI/res/drawable-mdpi/ic_notification_veto.png
new file mode 100644
index 0000000..f6299e9
--- /dev/null
+++ b/packages/SystemUI/res/drawable-mdpi/ic_notification_veto.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_notification_dnd.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_notification_dnd.png
new file mode 100644
index 0000000..fe44063
--- /dev/null
+++ b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_notification_dnd.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_notification_dnd_off.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_notification_dnd_off.png
new file mode 100644
index 0000000..8088a2f
--- /dev/null
+++ b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_notification_dnd_off.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_rotate_off_lanscape.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_rotate_off_lanscape.png
new file mode 100644
index 0000000..96bf2ec
--- /dev/null
+++ b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_rotate_off_lanscape.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_rotate_off_portrait.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_rotate_off_portrait.png
new file mode 100644
index 0000000..cc56778
--- /dev/null
+++ b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_rotate_off_portrait.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable/recent_overlay.png b/packages/SystemUI/res/drawable-mdpi/recent_overlay.png
index 4dfa3d9..4dfa3d9 100644
--- a/packages/SystemUI/res/drawable/recent_overlay.png
+++ b/packages/SystemUI/res/drawable-mdpi/recent_overlay.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable/recent_rez_border.png b/packages/SystemUI/res/drawable-mdpi/recent_rez_border.png
index ad025f5..ad025f5 100644
--- a/packages/SystemUI/res/drawable/recent_rez_border.png
+++ b/packages/SystemUI/res/drawable-mdpi/recent_rez_border.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/sysbar_signal_0.png b/packages/SystemUI/res/drawable-mdpi/sysbar_signal_0.png
new file mode 100644
index 0000000..7371571
--- /dev/null
+++ b/packages/SystemUI/res/drawable-mdpi/sysbar_signal_0.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/sysbar_signal_10.png b/packages/SystemUI/res/drawable-mdpi/sysbar_signal_10.png
new file mode 100644
index 0000000..5781e9a
--- /dev/null
+++ b/packages/SystemUI/res/drawable-mdpi/sysbar_signal_10.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/sysbar_signal_100.png b/packages/SystemUI/res/drawable-mdpi/sysbar_signal_100.png
new file mode 100644
index 0000000..c65728c
--- /dev/null
+++ b/packages/SystemUI/res/drawable-mdpi/sysbar_signal_100.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/sysbar_signal_20.png b/packages/SystemUI/res/drawable-mdpi/sysbar_signal_20.png
new file mode 100644
index 0000000..a249fa2
--- /dev/null
+++ b/packages/SystemUI/res/drawable-mdpi/sysbar_signal_20.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/sysbar_signal_30.png b/packages/SystemUI/res/drawable-mdpi/sysbar_signal_30.png
new file mode 100644
index 0000000..289c088
--- /dev/null
+++ b/packages/SystemUI/res/drawable-mdpi/sysbar_signal_30.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/sysbar_signal_40.png b/packages/SystemUI/res/drawable-mdpi/sysbar_signal_40.png
new file mode 100644
index 0000000..f49dbd6
--- /dev/null
+++ b/packages/SystemUI/res/drawable-mdpi/sysbar_signal_40.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/sysbar_signal_50.png b/packages/SystemUI/res/drawable-mdpi/sysbar_signal_50.png
new file mode 100644
index 0000000..2f83e68
--- /dev/null
+++ b/packages/SystemUI/res/drawable-mdpi/sysbar_signal_50.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/sysbar_signal_60.png b/packages/SystemUI/res/drawable-mdpi/sysbar_signal_60.png
new file mode 100644
index 0000000..bedc021
--- /dev/null
+++ b/packages/SystemUI/res/drawable-mdpi/sysbar_signal_60.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/sysbar_signal_70.png b/packages/SystemUI/res/drawable-mdpi/sysbar_signal_70.png
new file mode 100644
index 0000000..edd8c05
--- /dev/null
+++ b/packages/SystemUI/res/drawable-mdpi/sysbar_signal_70.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/sysbar_signal_80.png b/packages/SystemUI/res/drawable-mdpi/sysbar_signal_80.png
new file mode 100644
index 0000000..148e20c
--- /dev/null
+++ b/packages/SystemUI/res/drawable-mdpi/sysbar_signal_80.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/sysbar_signal_90.png b/packages/SystemUI/res/drawable-mdpi/sysbar_signal_90.png
new file mode 100644
index 0000000..5a90ccb
--- /dev/null
+++ b/packages/SystemUI/res/drawable-mdpi/sysbar_signal_90.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-hdpi/app_icon.png b/packages/SystemUI/res/drawable-xlarge-hdpi/app_icon.png
new file mode 100644
index 0000000..aedf7e7
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-hdpi/app_icon.png
Binary files differ
diff --git a/services/audioflinger/A2dpAudioInterface.cpp b/services/audioflinger/A2dpAudioInterface.cpp
index 995e31c..aee01ab 100644
--- a/services/audioflinger/A2dpAudioInterface.cpp
+++ b/services/audioflinger/A2dpAudioInterface.cpp
@@ -23,10 +23,13 @@
#include "A2dpAudioInterface.h"
#include "audio/liba2dp.h"
-
+#include <hardware_legacy/power.h>
namespace android {
+static const char *sA2dpWakeLock = "A2dpOutputStream";
+#define MAX_WRITE_RETRIES 5
+
// ----------------------------------------------------------------------------
//AudioHardwareInterface* A2dpAudioInterface::createA2dpInterface()
@@ -263,44 +266,55 @@ status_t A2dpAudioInterface::A2dpAudioStreamOut::set(
A2dpAudioInterface::A2dpAudioStreamOut::~A2dpAudioStreamOut()
{
LOGV("A2dpAudioStreamOut destructor");
- standby();
close();
LOGV("A2dpAudioStreamOut destructor returning from close()");
}
ssize_t A2dpAudioInterface::A2dpAudioStreamOut::write(const void* buffer, size_t bytes)
{
- Mutex::Autolock lock(mLock);
-
- size_t remaining = bytes;
status_t status = -1;
+ {
+ Mutex::Autolock lock(mLock);
- if (!mBluetoothEnabled || mClosing || mSuspended) {
- LOGV("A2dpAudioStreamOut::write(), but bluetooth disabled \
- mBluetoothEnabled %d, mClosing %d, mSuspended %d",
- mBluetoothEnabled, mClosing, mSuspended);
- goto Error;
- }
-
- status = init();
- if (status < 0)
- goto Error;
+ size_t remaining = bytes;
- while (remaining > 0) {
- status = a2dp_write(mData, buffer, remaining);
- if (status <= 0) {
- LOGE("a2dp_write failed err: %d\n", status);
+ if (!mBluetoothEnabled || mClosing || mSuspended) {
+ LOGV("A2dpAudioStreamOut::write(), but bluetooth disabled \
+ mBluetoothEnabled %d, mClosing %d, mSuspended %d",
+ mBluetoothEnabled, mClosing, mSuspended);
goto Error;
}
- remaining -= status;
- buffer = ((char *)buffer) + status;
- }
- mStandby = false;
+ if (mStandby) {
+ acquire_wake_lock (PARTIAL_WAKE_LOCK, sA2dpWakeLock);
+ mStandby = false;
+ }
+
+ status = init();
+ if (status < 0)
+ goto Error;
+
+ int retries = MAX_WRITE_RETRIES;
+ while (remaining > 0 && retries) {
+ status = a2dp_write(mData, buffer, remaining);
+ if (status < 0) {
+ LOGE("a2dp_write failed err: %d\n", status);
+ goto Error;
+ }
+ if (status == 0) {
+ retries--;
+ }
+ remaining -= status;
+ buffer = (char *)buffer + status;
+ }
- return bytes;
+ return bytes;
+ }
Error:
+
+ standby();
+
// Simulate audio output timing in case of error
usleep(((bytes * 1000 )/ frameSize() / sampleRate()) * 1000);
@@ -324,19 +338,22 @@ status_t A2dpAudioInterface::A2dpAudioStreamOut::init()
status_t A2dpAudioInterface::A2dpAudioStreamOut::standby()
{
- int result = 0;
-
- if (mClosing) {
- LOGV("Ignore standby, closing");
- return result;
- }
-
Mutex::Autolock lock(mLock);
+ return standby_l();
+}
+
+status_t A2dpAudioInterface::A2dpAudioStreamOut::standby_l()
+{
+ int result = NO_ERROR;
if (!mStandby) {
- result = a2dp_stop(mData);
- if (result == 0)
- mStandby = true;
+ LOGV_IF(mClosing || !mBluetoothEnabled, "Standby skip stop: closing %d enabled %d",
+ mClosing, mBluetoothEnabled);
+ if (!mClosing && mBluetoothEnabled) {
+ result = a2dp_stop(mData);
+ }
+ release_wake_lock(sA2dpWakeLock);
+ mStandby = true;
}
return result;
@@ -362,6 +379,9 @@ status_t A2dpAudioInterface::A2dpAudioStreamOut::setParameters(const String8& ke
key = String8("closing");
if (param.get(key, value) == NO_ERROR) {
mClosing = (value == "true");
+ if (mClosing) {
+ standby();
+ }
param.remove(key);
}
key = AudioParameter::keyRouting;
@@ -444,6 +464,7 @@ status_t A2dpAudioInterface::A2dpAudioStreamOut::close()
status_t A2dpAudioInterface::A2dpAudioStreamOut::close_l()
{
+ standby_l();
if (mData) {
LOGV("A2dpAudioStreamOut::close_l() calling a2dp_cleanup(mData)");
a2dp_cleanup(mData);
diff --git a/services/audioflinger/A2dpAudioInterface.h b/services/audioflinger/A2dpAudioInterface.h
index 48154f9..cef1926 100644
--- a/services/audioflinger/A2dpAudioInterface.h
+++ b/services/audioflinger/A2dpAudioInterface.h
@@ -103,6 +103,7 @@ private:
status_t setAddress(const char* address);
status_t setBluetoothEnabled(bool enabled);
status_t setSuspended(bool onOff);
+ status_t standby_l();
private:
int mFd;
diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java
index 5c32c38..89512ae 100644
--- a/services/java/com/android/server/WindowManagerService.java
+++ b/services/java/com/android/server/WindowManagerService.java
@@ -4918,6 +4918,10 @@ public class WindowManagerService extends IWindowManager.Stub
}
}
+ public void setStrictModeVisualIndicatorPreference(String value) {
+ SystemProperties.set(StrictMode.VISUAL_PROPERTY, value);
+ }
+
public void freezeRotation() {
if (!checkCallingPermission(android.Manifest.permission.SET_ORIENTATION,
"setRotation()")) {