Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
platform_frameworks_base-old
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Farzin Kazemzadeh
platform_frameworks_base-old
Commits
63f72806
Commit
63f72806
authored
10 years ago
by
Mark Renouf
Committed by
Android Git Automerger
10 years ago
Browse files
Options
Downloads
Plain Diff
am
11b14691
: Implement cliff guard for swipeDismiss gesture
* commit '
11b14691
': Implement cliff guard for swipeDismiss gesture
parents
4f8cd188
11b14691
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/java/com/android/internal/widget/SwipeDismissLayout.java
+9
-11
9 additions, 11 deletions
.../java/com/android/internal/widget/SwipeDismissLayout.java
core/res/res/values-watch/config.xml
+1
-1
1 addition, 1 deletion
core/res/res/values-watch/config.xml
with
10 additions
and
12 deletions
core/java/com/android/internal/widget/SwipeDismissLayout.java
+
9
−
11
View file @
63f72806
...
...
@@ -35,7 +35,7 @@ import android.widget.FrameLayout;
public
class
SwipeDismissLayout
extends
FrameLayout
{
private
static
final
String
TAG
=
"SwipeDismissLayout"
;
private
static
final
float
TRANSLATION_MIN_ALPHA
=
0.
5
f
;
private
static
final
float
DISMISS_MIN_PROGRESS
=
0.
6
f
;
public
interface
OnDismissedListener
{
void
onDismissed
(
SwipeDismissLayout
layout
);
...
...
@@ -77,6 +77,8 @@ public class SwipeDismissLayout extends FrameLayout {
private
OnDismissedListener
mDismissedListener
;
private
OnSwipeProgressChangedListener
mProgressListener
;
private
float
mLastX
;
public
SwipeDismissLayout
(
Context
context
)
{
super
(
context
);
init
(
context
);
...
...
@@ -95,7 +97,7 @@ public class SwipeDismissLayout extends FrameLayout {
private
void
init
(
Context
context
)
{
ViewConfiguration
vc
=
ViewConfiguration
.
get
(
getContext
());
mSlop
=
vc
.
getScaledTouchSlop
();
mMinFlingVelocity
=
vc
.
getScaledMinimumFlingVelocity
()
*
16
;
mMinFlingVelocity
=
vc
.
getScaledMinimumFlingVelocity
();
mMaxFlingVelocity
=
vc
.
getScaledMaximumFlingVelocity
();
mAnimationTime
=
getContext
().
getResources
().
getInteger
(
android
.
R
.
integer
.
config_shortAnimTime
);
...
...
@@ -193,8 +195,8 @@ public class SwipeDismissLayout extends FrameLayout {
case
MotionEvent
.
ACTION_MOVE
:
mVelocityTracker
.
addMovement
(
ev
);
mLastX
=
ev
.
getRawX
();
updateSwiping
(
ev
);
updateDismiss
(
ev
);
if
(
mSwiping
)
{
setProgress
(
ev
.
getRawX
()
-
mDownX
);
break
;
...
...
@@ -256,20 +258,16 @@ public class SwipeDismissLayout extends FrameLayout {
float
absVelocityX
=
Math
.
abs
(
velocityX
);
float
absVelocityY
=
Math
.
abs
(
mVelocityTracker
.
getYVelocity
());
if
(
deltaX
>
getWidth
()
/
2
)
{
mDismissed
=
true
;
}
else
if
(
absVelocityX
>=
mMinFlingVelocity
&&
absVelocityX
<=
mMaxFlingVelocity
&&
absVelocityY
<
absVelocityX
/
2
&&
velocityX
>
0
&&
deltaX
>
0
)
{
if
(
deltaX
>
(
getWidth
()
*
DISMISS_MIN_PROGRESS
)
&&
absVelocityX
<
mMinFlingVelocity
&&
ev
.
getRawX
()
>=
mLastX
)
{
mDismissed
=
true
;
}
}
// Check if the user tried to undo this.
if
(
mDismissed
&&
mSwiping
)
{
// Check if the user's finger is actually back
if
(
deltaX
<
getWidth
()
/
2
)
{
if
(
deltaX
<
(
getWidth
()
*
DISMISS_MIN_PROGRESS
)
)
{
mDismissed
=
false
;
}
}
...
...
This diff is collapsed.
Click to expand it.
core/res/res/values-watch/config.xml
+
1
−
1
View file @
63f72806
...
...
@@ -32,7 +32,7 @@
<dimen
name=
"config_viewConfigurationTouchSlop"
>
4dp
</dimen>
<!-- Minimum velocity to initiate a fling, as measured in dips per second. -->
<dimen
name=
"config_viewMinFlingVelocity"
>
50dp
</dimen>
<dimen
name=
"config_viewMinFlingVelocity"
>
50
0
dp
</dimen>
<!-- Maximum velocity to initiate a fling, as measured in dips per second. -->
<dimen
name=
"config_viewMaxFlingVelocity"
>
8000dp
</dimen>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment