summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/java/com/android/internal/widget/multiwaveview/GlowPadView.java47
-rw-r--r--core/java/com/android/internal/widget/multiwaveview/MultiWaveView.java47
-rw-r--r--core/res/res/layout-sw600dp/keyguard_screen_tab_unlock.xml1
-rw-r--r--core/res/res/layout-sw600dp/keyguard_screen_tab_unlock_land.xml1
-rw-r--r--core/res/res/layout/keyguard_screen_tab_unlock.xml1
-rw-r--r--core/res/res/layout/keyguard_screen_tab_unlock_land.xml1
-rwxr-xr-xcore/res/res/values/attrs.xml6
-rw-r--r--core/res/res/values/dimens.xml7
-rw-r--r--packages/SystemUI/res/layout-land/status_bar_search_panel.xml1
-rw-r--r--packages/SystemUI/res/layout-port/status_bar_search_panel.xml1
-rw-r--r--packages/SystemUI/res/layout-sw600dp/status_bar_search_panel.xml1
-rw-r--r--packages/SystemUI/res/layout-sw720dp/status_bar_search_panel.xml1
-rw-r--r--packages/SystemUI/res/values/dimens.xml7
13 files changed, 38 insertions, 84 deletions
diff --git a/core/java/com/android/internal/widget/multiwaveview/GlowPadView.java b/core/java/com/android/internal/widget/multiwaveview/GlowPadView.java
index 5096be6..837b7b8 100644
--- a/core/java/com/android/internal/widget/multiwaveview/GlowPadView.java
+++ b/core/java/com/android/internal/widget/multiwaveview/GlowPadView.java
@@ -115,7 +115,6 @@ public class GlowPadView extends View {
private int mMaxTargetWidth;
private float mOuterRadius = 0.0f;
- private float mHitRadius = 0.0f;
private float mSnapMargin = 0.0f;
private boolean mDragging;
private int mNewTargetResources;
@@ -211,7 +210,6 @@ public class GlowPadView extends View {
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.GlowPadView);
mInnerRadius = a.getDimension(R.styleable.GlowPadView_innerRadius, mInnerRadius);
mOuterRadius = a.getDimension(R.styleable.GlowPadView_outerRadius, mOuterRadius);
- mHitRadius = a.getDimension(R.styleable.GlowPadView_hitRadius, mHitRadius);
mSnapMargin = a.getDimension(R.styleable.GlowPadView_snapMargin, mSnapMargin);
mVibrationDuration = a.getInt(R.styleable.GlowPadView_vibrationDuration,
mVibrationDuration);
@@ -280,7 +278,6 @@ public class GlowPadView extends View {
private void dump() {
Log.v(TAG, "Outer Radius = " + mOuterRadius);
- Log.v(TAG, "HitRadius = " + mHitRadius);
Log.v(TAG, "SnapMargin = " + mSnapMargin);
Log.v(TAG, "FeedbackCount = " + mFeedbackCount);
Log.v(TAG, "VibrationDuration = " + mVibrationDuration);
@@ -799,7 +796,6 @@ public class GlowPadView extends View {
final int historySize = event.getHistorySize();
ArrayList<TargetDrawable> targets = mTargetDrawables;
int ntargets = targets.size();
- final boolean singleTarget = ntargets == 1;
float x = 0.0f;
float y = 0.0f;
for (int k = 0; k < historySize + 1; k++) {
@@ -812,31 +808,29 @@ public class GlowPadView extends View {
final float scale = touchRadius > mOuterRadius ? mOuterRadius / touchRadius : 1.0f;
float limitX = tx * scale;
float limitY = ty * scale;
+ double angleRad = Math.atan2(-ty, tx);
if (!mDragging) {
trySwitchToFirstTouchState(eventX, eventY);
}
if (mDragging) {
- if (singleTarget) {
- // Snap to outer ring if there's only one target
- float snapRadius = mOuterRadius - mSnapMargin;
- if (touchRadius > snapRadius) {
- activeTarget = 0;
- }
- } else {
- // For more than one target, snap to the closest one less than hitRadius away.
- float best = Float.MAX_VALUE;
- final float hitRadius2 = mHitRadius * mHitRadius;
- // Find first target in range
- for (int i = 0; i < ntargets; i++) {
- TargetDrawable target = targets.get(i);
- float dx = limitX - target.getX();
- float dy = limitY - target.getY();
- float dist2 = dx*dx + dy*dy;
- if (target.isEnabled() && dist2 < hitRadius2 && dist2 < best) {
+ // For multiple targets, snap to the one that matches
+ final float snapRadius = mOuterRadius - mSnapMargin;
+ final float snapDistance2 = snapRadius * snapRadius;
+ // Find first target in range
+ for (int i = 0; i < ntargets; i++) {
+ TargetDrawable target = targets.get(i);
+
+ double targetMinRad = (i - 0.5) * 2 * Math.PI / ntargets;
+ double targetMaxRad = (i + 0.5) * 2 * Math.PI / ntargets;
+ if (target.isEnabled()) {
+ boolean angleMatches =
+ (angleRad > targetMinRad && angleRad <= targetMaxRad) ||
+ (angleRad + 2 * Math.PI > targetMinRad &&
+ angleRad + 2 * Math.PI <= targetMaxRad);
+ if (angleMatches && (dist2(tx, ty) > snapDistance2)) {
activeTarget = i;
- best = dist2;
}
}
}
@@ -851,10 +845,7 @@ public class GlowPadView extends View {
if (activeTarget != -1) {
switchToState(STATE_SNAP, x,y);
- TargetDrawable target = targets.get(activeTarget);
- final float newX = singleTarget ? x : target.getX();
- final float newY = singleTarget ? y : target.getY();
- updateGlowPosition(newX, newY);
+ updateGlowPosition(x, y);
} else {
switchToState(STATE_TRACKING, x, y);
updateGlowPosition(x, y);
@@ -942,10 +933,6 @@ public class GlowPadView extends View {
if (mOuterRadius == 0.0f) {
mOuterRadius = Math.max(mOuterRing.getWidth(), mOuterRing.getHeight())/2.0f;
}
- if (mHitRadius == 0.0f) {
- // Use the radius of inscribed circle of the first target.
- mHitRadius = mTargetDrawables.get(0).getWidth() / 2.0f;
- }
if (mSnapMargin == 0.0f) {
mSnapMargin = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
SNAP_MARGIN_DEFAULT, getContext().getResources().getDisplayMetrics());
diff --git a/core/java/com/android/internal/widget/multiwaveview/MultiWaveView.java b/core/java/com/android/internal/widget/multiwaveview/MultiWaveView.java
index afeac00..10804c0 100644
--- a/core/java/com/android/internal/widget/multiwaveview/MultiWaveView.java
+++ b/core/java/com/android/internal/widget/multiwaveview/MultiWaveView.java
@@ -119,7 +119,6 @@ public class MultiWaveView extends View {
private int mMaxTargetWidth;
private float mOuterRadius = 0.0f;
- private float mHitRadius = 0.0f;
private float mSnapMargin = 0.0f;
private boolean mDragging;
private int mNewTargetResources;
@@ -213,7 +212,6 @@ public class MultiWaveView extends View {
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MultiWaveView);
mOuterRadius = a.getDimension(R.styleable.MultiWaveView_outerRadius, mOuterRadius);
- mHitRadius = a.getDimension(R.styleable.MultiWaveView_hitRadius, mHitRadius);
mSnapMargin = a.getDimension(R.styleable.MultiWaveView_snapMargin, mSnapMargin);
mVibrationDuration = a.getInt(R.styleable.MultiWaveView_vibrationDuration,
mVibrationDuration);
@@ -277,7 +275,6 @@ public class MultiWaveView extends View {
private void dump() {
Log.v(TAG, "Outer Radius = " + mOuterRadius);
- Log.v(TAG, "HitRadius = " + mHitRadius);
Log.v(TAG, "SnapMargin = " + mSnapMargin);
Log.v(TAG, "FeedbackCount = " + mFeedbackCount);
Log.v(TAG, "VibrationDuration = " + mVibrationDuration);
@@ -823,7 +820,6 @@ public class MultiWaveView extends View {
final int historySize = event.getHistorySize();
ArrayList<TargetDrawable> targets = mTargetDrawables;
int ntargets = targets.size();
- final boolean singleTarget = ntargets == 1;
float x = 0.0f;
float y = 0.0f;
for (int k = 0; k < historySize + 1; k++) {
@@ -836,31 +832,29 @@ public class MultiWaveView extends View {
final float scale = touchRadius > mOuterRadius ? mOuterRadius / touchRadius : 1.0f;
float limitX = tx * scale;
float limitY = ty * scale;
+ double angleRad = Math.atan2(-ty, tx);
if (!mDragging) {
trySwitchToFirstTouchState(eventX, eventY);
}
if (mDragging) {
- if (singleTarget) {
- // Snap to outer ring if there's only one target
- float snapRadius = mOuterRadius - mSnapMargin;
- if (touchRadius > snapRadius) {
- activeTarget = 0;
- }
- } else {
- // For more than one target, snap to the closest one less than hitRadius away.
- float best = Float.MAX_VALUE;
- final float hitRadius2 = mHitRadius * mHitRadius;
- // Find first target in range
- for (int i = 0; i < ntargets; i++) {
- TargetDrawable target = targets.get(i);
- float dx = limitX - target.getX();
- float dy = limitY - target.getY();
- float dist2 = dx*dx + dy*dy;
- if (target.isEnabled() && dist2 < hitRadius2 && dist2 < best) {
+ // For multiple targets, snap to the one that matches
+ final float snapRadius = mOuterRadius - mSnapMargin;
+ final float snapDistance2 = snapRadius * snapRadius;
+ // Find first target in range
+ for (int i = 0; i < ntargets; i++) {
+ TargetDrawable target = targets.get(i);
+
+ double targetMinRad = (i - 0.5) * 2 * Math.PI / ntargets;
+ double targetMaxRad = (i + 0.5) * 2 * Math.PI / ntargets;
+ if (target.isEnabled()) {
+ boolean angleMatches =
+ (angleRad > targetMinRad && angleRad <= targetMaxRad) ||
+ (angleRad + 2 * Math.PI > targetMinRad &&
+ angleRad + 2 * Math.PI <= targetMaxRad);
+ if (angleMatches && (dist2(tx, ty) > snapDistance2)) {
activeTarget = i;
- best = dist2;
}
}
}
@@ -875,10 +869,7 @@ public class MultiWaveView extends View {
if (activeTarget != -1) {
switchToState(STATE_SNAP, x,y);
- TargetDrawable target = targets.get(activeTarget);
- final float newX = singleTarget ? x : target.getX();
- final float newY = singleTarget ? y : target.getY();
- moveHandleTo(newX, newY, false);
+ moveHandleTo(x, y, false);
} else {
switchToState(STATE_TRACKING, x, y);
moveHandleTo(x, y, false);
@@ -972,10 +963,6 @@ public class MultiWaveView extends View {
if (mOuterRadius == 0.0f) {
mOuterRadius = Math.max(mOuterRing.getWidth(), mOuterRing.getHeight())/2.0f;
}
- if (mHitRadius == 0.0f) {
- // Use the radius of inscribed circle of the first target.
- mHitRadius = mTargetDrawables.get(0).getWidth() / 2.0f;
- }
if (mSnapMargin == 0.0f) {
mSnapMargin = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
SNAP_MARGIN_DEFAULT, getContext().getResources().getDisplayMetrics());
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 cd9c913..356e7cf 100644
--- a/core/res/res/layout-sw600dp/keyguard_screen_tab_unlock.xml
+++ b/core/res/res/layout-sw600dp/keyguard_screen_tab_unlock.xml
@@ -98,7 +98,6 @@
android:outerRadius="@dimen/glowpadview_target_placement_radius"
android:innerRadius="@dimen/glowpadview_inner_radius"
android:snapMargin="@dimen/glowpadview_snap_margin"
- android:hitRadius="@dimen/glowpadview_hit_radius"
android:feedbackCount="1"
android:vibrationDuration="20"
android:glowRadius="@dimen/glowpadview_glow_radius"
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 32ca602..cb1cb21 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
@@ -98,7 +98,6 @@
android:outerRadius="@dimen/glowpadview_target_placement_radius"
android:innerRadius="@dimen/glowpadview_inner_radius"
android:snapMargin="@dimen/glowpadview_snap_margin"
- android:hitRadius="@dimen/glowpadview_hit_radius"
android:feedbackCount="1"
android:vibrationDuration="20"
android:glowRadius="@dimen/glowpadview_glow_radius"
diff --git a/core/res/res/layout/keyguard_screen_tab_unlock.xml b/core/res/res/layout/keyguard_screen_tab_unlock.xml
index 4e646a6..91f65e9 100644
--- a/core/res/res/layout/keyguard_screen_tab_unlock.xml
+++ b/core/res/res/layout/keyguard_screen_tab_unlock.xml
@@ -139,7 +139,6 @@
android:outerRadius="@dimen/glowpadview_target_placement_radius"
android:innerRadius="@dimen/glowpadview_inner_radius"
android:snapMargin="@dimen/glowpadview_snap_margin"
- android:hitRadius="@dimen/glowpadview_hit_radius"
android:feedbackCount="1"
android:vibrationDuration="20"
android:glowRadius="@dimen/glowpadview_glow_radius"
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 5a357fb..8b9d8e4 100644
--- a/core/res/res/layout/keyguard_screen_tab_unlock_land.xml
+++ b/core/res/res/layout/keyguard_screen_tab_unlock_land.xml
@@ -144,7 +144,6 @@
android:outerRadius="@dimen/glowpadview_target_placement_radius"
android:innerRadius="@dimen/glowpadview_inner_radius"
android:snapMargin="@dimen/glowpadview_snap_margin"
- android:hitRadius="@dimen/glowpadview_hit_radius"
android:feedbackCount="1"
android:vibrationDuration="20"
android:glowRadius="@dimen/glowpadview_glow_radius"
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index 00077512..3a7253b 100755
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -5405,9 +5405,6 @@
<!-- Outer radius of glow area. Target icons will be drawn on this circle. -->
<attr name="outerRadius"/>
- <!-- Size of target radius. Points within this distance of target center is a "hit". -->
- <attr name="hitRadius"/>
-
<!-- Radius of glow under finger. -->
<attr name="glowRadius" format="dimension" />
@@ -5450,9 +5447,6 @@
<!-- Outer radius of target circle. Icons will be drawn on this circle. -->
<attr name="outerRadius" format="dimension" />
- <!-- Size of target radius. Points within this distance of target center is a "hit". -->
- <attr name="hitRadius" format="dimension" />
-
<!-- Tactile feedback duration for actions. Set to '0' for no vibration. -->
<attr name="vibrationDuration" format="integer"/>
diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml
index ffbcb95..f30943a 100644
--- a/core/res/res/values/dimens.xml
+++ b/core/res/res/values/dimens.xml
@@ -79,11 +79,8 @@
<!-- Default glow radius for GlowPadView -->
<dimen name="glowpadview_glow_radius">75dip</dimen>
- <!-- Default distance beyond which GlowPadView snaps to the target radius -->
- <dimen name="glowpadview_snap_margin">20dip</dimen>
-
- <!-- Default distance from each snap target that GlowPadView considers a "hit" -->
- <dimen name="glowpadview_hit_radius">60dip</dimen>
+ <!-- Default distance beyond which GlowPadView snaps to the matching target -->
+ <dimen name="glowpadview_snap_margin">40dip</dimen>
<!-- Default distance from each snap target that GlowPadView considers a "hit" -->
<dimen name="glowpadview_inner_radius">15dip</dimen>
diff --git a/packages/SystemUI/res/layout-land/status_bar_search_panel.xml b/packages/SystemUI/res/layout-land/status_bar_search_panel.xml
index e6c0087..c8a120d 100644
--- a/packages/SystemUI/res/layout-land/status_bar_search_panel.xml
+++ b/packages/SystemUI/res/layout-land/status_bar_search_panel.xml
@@ -54,7 +54,6 @@
prvandroid:outerRadius="@dimen/navbar_search_outerring_radius"
prvandroid:innerRadius="@*android:dimen/glowpadview_inner_radius"
prvandroid:snapMargin="@dimen/navbar_search_snap_margin"
- prvandroid:hitRadius="@dimen/navbar_search_hit_radius"
prvandroid:feedbackCount="0"
prvandroid:vibrationDuration="@integer/config_vibration_duration"
prvandroid:alwaysTrackFinger="true"
diff --git a/packages/SystemUI/res/layout-port/status_bar_search_panel.xml b/packages/SystemUI/res/layout-port/status_bar_search_panel.xml
index 3828136..1e4bb57 100644
--- a/packages/SystemUI/res/layout-port/status_bar_search_panel.xml
+++ b/packages/SystemUI/res/layout-port/status_bar_search_panel.xml
@@ -54,7 +54,6 @@
prvandroid:outerRadius="@dimen/navbar_search_outerring_radius"
prvandroid:innerRadius="@*android:dimen/glowpadview_inner_radius"
prvandroid:snapMargin="@dimen/navbar_search_snap_margin"
- prvandroid:hitRadius="@dimen/navbar_search_hit_radius"
prvandroid:feedbackCount="0"
prvandroid:vibrationDuration="@integer/config_vibration_duration"
prvandroid:alwaysTrackFinger="true"
diff --git a/packages/SystemUI/res/layout-sw600dp/status_bar_search_panel.xml b/packages/SystemUI/res/layout-sw600dp/status_bar_search_panel.xml
index c17f858..3b6c52e 100644
--- a/packages/SystemUI/res/layout-sw600dp/status_bar_search_panel.xml
+++ b/packages/SystemUI/res/layout-sw600dp/status_bar_search_panel.xml
@@ -40,7 +40,6 @@
prvandroid:outerRadius="@dimen/navbar_search_outerring_radius"
prvandroid:innerRadius="@*android:dimen/glowpadview_inner_radius"
prvandroid:snapMargin="@dimen/navbar_search_snap_margin"
- prvandroid:hitRadius="@dimen/navbar_search_hit_radius"
prvandroid:feedbackCount="0"
prvandroid:vibrationDuration="@integer/config_vibration_duration"
prvandroid:alwaysTrackFinger="true"
diff --git a/packages/SystemUI/res/layout-sw720dp/status_bar_search_panel.xml b/packages/SystemUI/res/layout-sw720dp/status_bar_search_panel.xml
index 100f81d..8c2360e 100644
--- a/packages/SystemUI/res/layout-sw720dp/status_bar_search_panel.xml
+++ b/packages/SystemUI/res/layout-sw720dp/status_bar_search_panel.xml
@@ -41,7 +41,6 @@
prvandroid:outerRadius="@dimen/navbar_search_outerring_radius"
prvandroid:innerRadius="@*android:dimen/glowpadview_inner_radius"
prvandroid:snapMargin="@dimen/navbar_search_snap_margin"
- prvandroid:hitRadius="@dimen/navbar_search_hit_radius"
prvandroid:feedbackCount="0"
prvandroid:vibrationDuration="@integer/config_vibration_duration"
prvandroid:alwaysTrackFinger="true"
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index c88ae2a..6a96c6b 100644
--- a/packages/SystemUI/res/values/dimens.xml
+++ b/packages/SystemUI/res/values/dimens.xml
@@ -110,11 +110,8 @@
<!-- The width of the view containing the menu status bar icon -->
<dimen name="navigation_menu_key_width">40dip</dimen>
- <!-- Default distance beyond which snaps to the target radius -->
- <dimen name="navbar_search_snap_margin">20dip</dimen>
-
- <!-- Default distance from each snap target considers a "hit" -->
- <dimen name="navbar_search_hit_radius">60dip</dimen>
+ <!-- Default distance beyond which snaps to the matching target -->
+ <dimen name="navbar_search_snap_margin">40dip</dimen>
<!-- Diameter of outer shape drawable shown in navbar search-->
<dimen name="navbar_search_outerring_diameter">340dp</dimen>