Merge change 9669
* changes:
Take density in to account when reordering playlist items.
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
new file mode 100644
index 0000000..a2d1f10
--- /dev/null
+++ b/res/values/dimens.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2009 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.
+-->
+
+<resources>
+ <!-- height of a normal list item in edit playlist mode -->
+ <dimen name="normal_height">64dip</dimen>
+ <!-- height of an expanded list item in edit playlist mode -->
+ <dimen name="expanded_height">128dip</dimen>
+</resources>
diff --git a/src/com/android/music/TouchInterceptor.java b/src/com/android/music/TouchInterceptor.java
index 4276b7b..8476011 100644
--- a/src/com/android/music/TouchInterceptor.java
+++ b/src/com/android/music/TouchInterceptor.java
@@ -18,6 +18,7 @@
import android.content.Context;
import android.content.SharedPreferences;
+import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.PixelFormat;
import android.graphics.Rect;
@@ -32,7 +33,6 @@
import android.view.GestureDetector.SimpleOnGestureListener;
import android.widget.AdapterView;
import android.widget.ImageView;
-import android.widget.ListAdapter;
import android.widget.ListView;
public class TouchInterceptor extends ListView {
@@ -57,12 +57,17 @@
private Rect mTempRect = new Rect();
private Bitmap mDragBitmap;
private final int mTouchSlop;
+ private int mItemHeightNormal;
+ private int mItemHeightExpanded;
public TouchInterceptor(Context context, AttributeSet attrs) {
super(context, attrs);
SharedPreferences pref = context.getSharedPreferences("Music", 3);
mRemoveMode = pref.getInt("deletemode", -1);
mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
+ Resources res = getResources();
+ mItemHeightNormal = res.getDimensionPixelSize(R.dimen.normal_height);
+ mItemHeightExpanded = res.getDimensionPixelSize(R.dimen.expanded_height);
}
@Override
@@ -107,7 +112,8 @@
View dragger = item.findViewById(R.id.icon);
Rect r = mTempRect;
dragger.getDrawingRect(r);
- if (x < r.right) {
+ // The dragger icon itself is quite small, so pretend the touch area is bigger
+ if (x < r.right * 2) {
item.setDrawingCacheEnabled(true);
// Create a copy of the drawing cache so that it does not get recycled
// by the framework when the list tries to clean up memory
@@ -189,7 +195,7 @@
}
}
ViewGroup.LayoutParams params = v.getLayoutParams();
- params.height = 64;
+ params.height = mItemHeightNormal;
v.setLayoutParams(params);
v.setVisibility(View.VISIBLE);
}
@@ -220,7 +226,7 @@
if (vv == null) {
break;
}
- int height = 64;
+ int height = mItemHeightNormal;
int visibility = View.VISIBLE;
if (vv.equals(first)) {
// processing the item that is being dragged
@@ -233,7 +239,7 @@
}
} else if (i == childnum) {
if (mDragPos < getCount() - 1) {
- height = 128;
+ height = mItemHeightExpanded;
}
}
ViewGroup.LayoutParams params = vv.getLayoutParams();