Merge "Change snap behavior for lock screen" into jb-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
71fc205d11
@ -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());
|
||||
|
@ -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());
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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"/>
|
||||
|
||||
|
@ -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>
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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>
|
||||
|
Reference in New Issue
Block a user