summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJim Miller <jaggies@google.com>2012-05-07 14:34:00 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-05-07 14:34:00 -0700
commit06e8d6647db54aa76dda92a5a785737e66d262de (patch)
tree1056d80d1451e658c62ed1340b0598306b52a231 /core
parent476b03b0c0d5cae4d1b114c6f80858d59ba36cad (diff)
parent354619c1cc1b4668c81c5368b2256335cc9e8538 (diff)
downloadframeworks_base-06e8d6647db54aa76dda92a5a785737e66d262de.zip
frameworks_base-06e8d6647db54aa76dda92a5a785737e66d262de.tar.gz
frameworks_base-06e8d6647db54aa76dda92a5a785737e66d262de.tar.bz2
Merge "Fix 6397736: Swipe up to search layout fixes" into jb-dev
Diffstat (limited to 'core')
-rw-r--r--core/java/com/android/internal/widget/multiwaveview/MultiWaveView.java101
-rw-r--r--core/res/res/layout-sw600dp/keyguard_screen_tab_unlock.xml8
-rw-r--r--core/res/res/layout-sw600dp/keyguard_screen_tab_unlock_land.xml7
-rw-r--r--core/res/res/layout/keyguard_screen_tab_unlock.xml3
-rw-r--r--core/res/res/layout/keyguard_screen_tab_unlock_land.xml5
-rw-r--r--core/res/res/values-sw600dp-land/arrays.xml4
-rwxr-xr-xcore/res/res/values/attrs.xml11
7 files changed, 99 insertions, 40 deletions
diff --git a/core/java/com/android/internal/widget/multiwaveview/MultiWaveView.java b/core/java/com/android/internal/widget/multiwaveview/MultiWaveView.java
index 624dea8..3ba2bc6 100644
--- a/core/java/com/android/internal/widget/multiwaveview/MultiWaveView.java
+++ b/core/java/com/android/internal/widget/multiwaveview/MultiWaveView.java
@@ -32,6 +32,7 @@ import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
import android.util.TypedValue;
+import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.view.accessibility.AccessibilityEvent;
@@ -99,8 +100,11 @@ public class MultiWaveView extends View {
private float mTapRadius;
private float mWaveCenterX;
private float mWaveCenterY;
- private float mVerticalOffset;
+ private int mMaxTargetHeight;
+ private int mMaxTargetWidth;
private float mHorizontalOffset;
+ private float mVerticalOffset;
+
private float mOuterRadius = 0.0f;
private float mHitRadius = 0.0f;
private float mSnapMargin = 0.0f;
@@ -142,6 +146,9 @@ public class MultiWaveView extends View {
private int mTargetDescriptionsResourceId;
private int mDirectionDescriptionsResourceId;
private boolean mAlwaysTrackFinger;
+ private int mHorizontalInset;
+ private int mVerticalInset;
+ private int mGravity = Gravity.TOP;
public MultiWaveView(Context context) {
this(context, null);
@@ -153,10 +160,9 @@ public class MultiWaveView extends View {
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MultiWaveView);
mOuterRadius = a.getDimension(R.styleable.MultiWaveView_outerRadius, mOuterRadius);
- mHorizontalOffset = a.getDimension(R.styleable.MultiWaveView_horizontalOffset,
- mHorizontalOffset);
- mVerticalOffset = a.getDimension(R.styleable.MultiWaveView_verticalOffset,
- mVerticalOffset);
+// mHorizontalOffset = a.getDimension(R.styleable.MultiWaveView_horizontalOffset,
+// mHorizontalOffset);
+// mVerticalOffset = a.getDimension(R.styleable.MultiWaveView_verticalOffset, mVerticalOffset);
mHitRadius = a.getDimension(R.styleable.MultiWaveView_hitRadius, mHitRadius);
mSnapMargin = a.getDimension(R.styleable.MultiWaveView_snapMargin, mSnapMargin);
mVibrationDuration = a.getInt(R.styleable.MultiWaveView_vibrationDuration,
@@ -169,6 +175,7 @@ public class MultiWaveView extends View {
mOuterRing = new TargetDrawable(res,
a.peekValue(R.styleable.MultiWaveView_waveDrawable).resourceId);
mAlwaysTrackFinger = a.getBoolean(R.styleable.MultiWaveView_alwaysTrackFinger, false);
+ mGravity = a.getInt(R.styleable.MultiWaveView_gravity, Gravity.TOP);
// Read chevron animation drawables
final int chevrons[] = { R.styleable.MultiWaveView_leftChevronDrawable,
@@ -231,16 +238,16 @@ public class MultiWaveView extends View {
@Override
protected int getSuggestedMinimumWidth() {
- // View should be large enough to contain the background + target drawable on either edge
- return mOuterRing.getWidth()
- + (mTargetDrawables.size() > 0 ? (mTargetDrawables.get(0).getWidth()/2) : 0);
+ // View should be large enough to contain the background + handle and
+ // target drawable on either edge.
+ return mOuterRing.getWidth() + mMaxTargetWidth;
}
@Override
protected int getSuggestedMinimumHeight() {
- // View should be large enough to contain the unlock ring + target drawable on either edge
- return mOuterRing.getHeight()
- + (mTargetDrawables.size() > 0 ? (mTargetDrawables.get(0).getHeight()/2) : 0);
+ // View should be large enough to contain the unlock ring + target and
+ // target drawable on either edge
+ return mOuterRing.getHeight() + mMaxTargetHeight;
}
private int resolveMeasured(int measureSpec, int desired)
@@ -265,9 +272,10 @@ public class MultiWaveView extends View {
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
final int minimumWidth = getSuggestedMinimumWidth();
final int minimumHeight = getSuggestedMinimumHeight();
- int viewWidth = resolveMeasured(widthMeasureSpec, minimumWidth);
- int viewHeight = resolveMeasured(heightMeasureSpec, minimumHeight);
- setMeasuredDimension(viewWidth, viewHeight);
+ int computedWidth = resolveMeasured(widthMeasureSpec, minimumWidth);
+ int computedHeight = resolveMeasured(heightMeasureSpec, minimumHeight);
+ setupGravity((computedWidth - minimumWidth), (computedHeight - minimumHeight));
+ setMeasuredDimension(computedWidth, computedHeight);
}
private void switchToState(int state, float x, float y) {
@@ -521,14 +529,25 @@ public class MultiWaveView extends View {
TypedArray array = res.obtainTypedArray(resourceId);
int count = array.length();
ArrayList<TargetDrawable> targetDrawables = new ArrayList<TargetDrawable>(count);
+ int maxWidth = mHandleDrawable.getWidth();
+ int maxHeight = mHandleDrawable.getHeight();
for (int i = 0; i < count; i++) {
TypedValue value = array.peekValue(i);
- targetDrawables.add(new TargetDrawable(res, value != null ? value.resourceId : 0));
+ TargetDrawable target= new TargetDrawable(res, value != null ? value.resourceId : 0);
+ targetDrawables.add(target);
+ maxWidth = Math.max(maxWidth, target.getWidth());
+ maxHeight = Math.max(maxHeight, target.getHeight());
+ }
+ if (mMaxTargetWidth != maxWidth || mMaxTargetHeight != maxHeight) {
+ mMaxTargetWidth = maxWidth;
+ mMaxTargetHeight = maxHeight;
+ requestLayout(); // required to resize layout and call updateTargetPositions()
+ } else {
+ updateTargetPositions();
}
array.recycle();
mTargetResourceId = resourceId;
mTargetDrawables = targetDrawables;
- updateTargetPositions();
}
/**
@@ -638,23 +657,27 @@ public class MultiWaveView extends View {
boolean handled = false;
switch (action) {
case MotionEvent.ACTION_DOWN:
+ if (DEBUG) Log.v(TAG, "*** DOWN ***");
handleDown(event);
handled = true;
break;
case MotionEvent.ACTION_MOVE:
+ if (DEBUG) Log.v(TAG, "*** MOVE ***");
handleMove(event);
handled = true;
break;
case MotionEvent.ACTION_UP:
+ if (DEBUG) Log.v(TAG, "*** UP ***");
handleMove(event);
handleUp(event);
handled = true;
break;
case MotionEvent.ACTION_CANCEL:
- handleMove(event);
+ if (DEBUG) Log.v(TAG, "*** CANCEL ***");
+ // handleMove(event);
handleCancel(event);
handled = true;
break;
@@ -795,6 +818,11 @@ public class MultiWaveView extends View {
}
mGrabbedState = newState;
if (mOnTriggerListener != null) {
+ if (newState == OnTriggerListener.NO_HANDLE) {
+ mOnTriggerListener.onReleased(this, OnTriggerListener.CENTER_HANDLE);
+ } else {
+ mOnTriggerListener.onGrabbed(this, OnTriggerListener.CENTER_HANDLE);
+ }
mOnTriggerListener.onGrabbedStateChange(this, mGrabbedState);
}
}
@@ -832,13 +860,45 @@ public class MultiWaveView extends View {
moveHandleTo(centerX, centerY, false);
}
+ private void setupGravity(int dx, int dy) {
+ final int layoutDirection = getResolvedLayoutDirection();
+ final int absoluteGravity = Gravity.getAbsoluteGravity(mGravity, layoutDirection);
+
+ switch (absoluteGravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
+ case Gravity.LEFT:
+ mHorizontalInset = 0;
+ break;
+ case Gravity.RIGHT:
+ mHorizontalInset = dx;
+ break;
+ case Gravity.CENTER_HORIZONTAL:
+ default:
+ mHorizontalInset = dx / 2;
+ break;
+ }
+ switch (absoluteGravity & Gravity.VERTICAL_GRAVITY_MASK) {
+ case Gravity.TOP:
+ mVerticalInset = 0;
+ break;
+ case Gravity.BOTTOM:
+ mVerticalInset = dy;
+ break;
+ case Gravity.CENTER_VERTICAL:
+ default:
+ mVerticalInset = dy / 2;
+ break;
+ }
+ }
+
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
final int width = right - left;
final int height = bottom - top;
- float newWaveCenterX = mHorizontalOffset + Math.max(width, mOuterRing.getWidth() ) / 2;
- float newWaveCenterY = mVerticalOffset + Math.max(height, mOuterRing.getHeight()) / 2;
+ float newWaveCenterX = mHorizontalOffset + mHorizontalInset
+ + Math.max(width, mMaxTargetWidth + mOuterRing.getWidth()) / 2;
+ float newWaveCenterY = mVerticalOffset + mVerticalInset
+ + Math.max(height, + mMaxTargetHeight + mOuterRing.getHeight()) / 2;
if (newWaveCenterX != mWaveCenterX || newWaveCenterY != mWaveCenterY) {
if (mWaveCenterX == 0 && mWaveCenterY == 0) {
performInitialLayout(newWaveCenterX, newWaveCenterY);
@@ -848,9 +908,8 @@ public class MultiWaveView extends View {
mOuterRing.setX(mWaveCenterX);
mOuterRing.setY(Math.max(mWaveCenterY, mWaveCenterY));
-
- updateTargetPositions();
}
+ updateTargetPositions();
if (DEBUG) dump();
}
diff --git a/core/res/res/layout-sw600dp/keyguard_screen_tab_unlock.xml b/core/res/res/layout-sw600dp/keyguard_screen_tab_unlock.xml
index 73dadb4..66cf98d 100644
--- a/core/res/res/layout-sw600dp/keyguard_screen_tab_unlock.xml
+++ b/core/res/res/layout-sw600dp/keyguard_screen_tab_unlock.xml
@@ -85,10 +85,10 @@
<com.android.internal.widget.multiwaveview.MultiWaveView
android:id="@+id/unlock_widget"
android:orientation="horizontal"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_alignParentBottom="true"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
android:layout_gravity="center"
+ android:gravity="center"
android:targetDrawables="@array/lockscreen_targets_with_camera"
android:targetDescriptions="@array/lockscreen_target_descriptions_with_camera"
@@ -99,8 +99,6 @@
android:snapMargin="@dimen/multiwaveview_snap_margin"
android:hitRadius="@dimen/multiwaveview_hit_radius"
android:rightChevronDrawable="@drawable/ic_lockscreen_chevron_right"
- android:horizontalOffset="0dip"
- android:verticalOffset="60dip"
android:feedbackCount="3"
android:vibrationDuration="20"
/>
diff --git a/core/res/res/layout-sw600dp/keyguard_screen_tab_unlock_land.xml b/core/res/res/layout-sw600dp/keyguard_screen_tab_unlock_land.xml
index 10b1ace..65b442b 100644
--- a/core/res/res/layout-sw600dp/keyguard_screen_tab_unlock_land.xml
+++ b/core/res/res/layout-sw600dp/keyguard_screen_tab_unlock_land.xml
@@ -84,10 +84,11 @@
<com.android.internal.widget.multiwaveview.MultiWaveView
android:id="@+id/unlock_widget"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
android:layout_rowSpan="7"
android:layout_gravity="center_vertical|center_horizontal"
+ android:gravity="center"
android:targetDrawables="@array/lockscreen_targets_with_camera"
android:targetDescriptions="@array/lockscreen_target_descriptions_with_camera"
@@ -100,8 +101,6 @@
android:rightChevronDrawable="@drawable/ic_lockscreen_chevron_right"
android:feedbackCount="3"
android:vibrationDuration="20"
- android:horizontalOffset="0dip"
- android:verticalOffset="0dip"
/>
<!-- emergency call button shown when sim is PUKd and tab_selector is hidden -->
diff --git a/core/res/res/layout/keyguard_screen_tab_unlock.xml b/core/res/res/layout/keyguard_screen_tab_unlock.xml
index 0ec8f75..3fd3023 100644
--- a/core/res/res/layout/keyguard_screen_tab_unlock.xml
+++ b/core/res/res/layout/keyguard_screen_tab_unlock.xml
@@ -129,6 +129,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
+ android:gravity="top"
android:targetDrawables="@array/lockscreen_targets_with_camera"
android:targetDescriptions="@array/lockscreen_target_descriptions_with_camera"
@@ -139,8 +140,6 @@
android:snapMargin="@dimen/multiwaveview_snap_margin"
android:hitRadius="@dimen/multiwaveview_hit_radius"
android:rightChevronDrawable="@drawable/ic_lockscreen_chevron_right"
- android:horizontalOffset="0dip"
- android:verticalOffset="60dip"
android:feedbackCount="3"
android:vibrationDuration="20"
/>
diff --git a/core/res/res/layout/keyguard_screen_tab_unlock_land.xml b/core/res/res/layout/keyguard_screen_tab_unlock_land.xml
index 294f91e..cd03c10 100644
--- a/core/res/res/layout/keyguard_screen_tab_unlock_land.xml
+++ b/core/res/res/layout/keyguard_screen_tab_unlock_land.xml
@@ -131,9 +131,10 @@
<!-- Column 2 -->
<com.android.internal.widget.multiwaveview.MultiWaveView
android:id="@+id/unlock_widget"
- android:layout_width="200dip"
+ android:layout_width="302dip"
android:layout_height="match_parent"
android:layout_rowSpan="7"
+ android:gravity="center"
android:targetDrawables="@array/lockscreen_targets_with_camera"
android:targetDescriptions="@array/lockscreen_target_descriptions_with_camera"
@@ -146,8 +147,6 @@
android:topChevronDrawable="@drawable/ic_lockscreen_chevron_up"
android:feedbackCount="3"
android:vibrationDuration="20"
- android:horizontalOffset="0dip"
- android:verticalOffset="0dip"
/>
<!-- Music transport control -->
diff --git a/core/res/res/values-sw600dp-land/arrays.xml b/core/res/res/values-sw600dp-land/arrays.xml
index 6304bc0..6a09cf8 100644
--- a/core/res/res/values-sw600dp-land/arrays.xml
+++ b/core/res/res/values-sw600dp-land/arrays.xml
@@ -57,14 +57,14 @@
<array name="lockscreen_targets_with_camera">
<item>@drawable/ic_lockscreen_unlock</item>
- <item>@null</item>
+ <item>@drawable/ic_lockscreen_search</item>
<item>@drawable/ic_lockscreen_camera</item>
<item>@null</item>
</array>
<array name="lockscreen_target_descriptions_with_camera">
<item>@string/description_target_unlock</item>
- <item>@null</item>
+ <item>@string/description_target_search</item>
<item>@string/description_target_camera</item>
<item>@null</item>
</array>
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index 9fa666e..484de0d 100755
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -3107,7 +3107,7 @@
<attr name="singleLine" format="boolean" />
<!-- Specifies whether the widget is enabled. The interpretation of the enabled state varies by subclass.
For example, a non-enabled EditText prevents the user from editing the contained text, and
- a non-enabled Button prevents the user from tapping the button.
+ a non-enabled Button prevents the user from tapping the button.
The appearance of enabled and non-enabled widgets may differ, if the drawables referenced
from evaluating state_enabled differ. -->
<attr name="enabled" format="boolean" />
@@ -5378,12 +5378,17 @@
<!-- Number of waves/chevrons to show in animation. -->
<attr name="feedbackCount" format="integer" />
- <!-- Used to shift center of pattern vertically. -->
+ <!-- {@deprecated Not used by the framework. Use android:gravity instead}
+ Used to shift center of pattern vertically. -->
<attr name="verticalOffset" format="dimension" />
- <!-- Used to shift center of pattern horizontally. -->
+ <!-- {@deprecated Not used by the framework. Use android:gravity instead}
+ Used to shift center of pattern horizontally. -->
<attr name="horizontalOffset" format="dimension" />
+ <!-- How the items in this layout should be positioned -->
+ <attr name="gravity" />
+
<!-- Used when the handle shouldn't wait to be hit before following the finger -->
<attr name="alwaysTrackFinger" format="boolean" />
</declare-styleable>