Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 00fcfe5e authored by Steve Kondik's avatar Steve Kondik Committed by Gerrit Code Review
Browse files

Merge "Change notification swipe-to-clear to use velocity" into froyo

parents a1a5b488 43c2da99
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
/* //device/apps/common/res/anim/slide_out_right_basic.xml
**
** Copyright 2010, 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.
*/
-->

<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromXDelta="0" android:toXDelta="-100%p"
    android:duration="@android:integer/config_mediumAnimTime" />
 No newline at end of file
+23 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
/* //device/apps/common/res/anim/slide_out_right_basic.xml
**
** Copyright 2010, 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.
*/
-->

<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromXDelta="0" android:toXDelta="100%p"
    android:duration="@android:integer/config_mediumAnimTime" />
 No newline at end of file
+16 −22
Original line number Diff line number Diff line
/*
 * Copyright (C) 2007 The Android Open Source Project
 * Copyright (C) 2010 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.
@@ -21,34 +21,36 @@ import android.os.Handler;
import android.util.AttributeSet;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.animation.TranslateAnimation;
import android.view.ViewConfiguration;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.LinearLayout;

public class LatestItemContainer extends LinearLayout {
    private static final int MAJOR_MOVE = 50;
    private static final int ANIM_DURATION = 400;
    private final GestureDetector mGestureDetector;

    private Runnable mSwipeCallback = null;
    private TranslateAnimation outRight;
    private TranslateAnimation outLeft;

    private final Handler mHandler = new Handler();

    public LatestItemContainer(Context context, AttributeSet attrs) {
    public LatestItemContainer(final Context context, AttributeSet attrs) {
        super(context, attrs);

        mGestureDetector =
                new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
        mGestureDetector = new GestureDetector(context,
                new GestureDetector.SimpleOnGestureListener() {
                    @Override
                    public boolean onFling(MotionEvent e1, MotionEvent e2, float vX, float vY) {
                        if (mSwipeCallback != null) {
                            int dx = (int) (e2.getX() - e1.getX());
                            if (Math.abs(dx) > MAJOR_MOVE && Math.abs(vX) > Math.abs(vY)) {
                            if (Math.abs(vX) > Math.abs(vY)) {
                                int id;
                                if (vX > 0) {
                                    startAnimation(outRight);
                                    id = com.android.internal.R.anim.slide_out_right_basic;
                                } else {
                                    startAnimation(outLeft);
                                    id = com.android.internal.R.anim.slide_out_left_basic;
                                }
                                mHandler.postDelayed(mSwipeCallback, ANIM_DURATION);
                                Animation animation = AnimationUtils.loadAnimation(context, id);
                                startAnimation(animation);
                                mHandler.postDelayed(mSwipeCallback, animation.getDuration());
                                return true;
                            }
                        }
@@ -57,14 +59,6 @@ public class LatestItemContainer extends LinearLayout {
                });
    }

    @Override
    public void onSizeChanged(int w, int h, int oldW, int oldH) {
        outRight = new TranslateAnimation(0, w, 0, 0);
        outLeft = new TranslateAnimation(0, -w, 0, 0);
        outRight.setDuration(ANIM_DURATION);
        outLeft.setDuration(ANIM_DURATION);
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent event) {
        boolean handled = mGestureDetector.onTouchEvent(event);