Search in sources :

Example 41 with ViewConfiguration

use of android.view.ViewConfiguration in project android_frameworks_base by crdroidandroid.

the class AbsListView method initAbsListView.

private void initAbsListView() {
    // Setting focusable in touch mode will set the focusable property to true
    setClickable(true);
    setFocusableInTouchMode(true);
    setWillNotDraw(false);
    setAlwaysDrawnWithCacheEnabled(false);
    boolean scrollingCacheEnabled = (mScrollingCacheProperty < 2);
    setScrollingCacheEnabled(scrollingCacheEnabled);
    final ViewConfiguration configuration = ViewConfiguration.get(mContext);
    mTouchSlop = configuration.getScaledTouchSlop();
    mScrollFactor = configuration.getScaledScrollFactor();
    mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
    mDecacheThreshold = mMaximumVelocity / 2;
    mOverscrollDistance = configuration.getScaledOverscrollDistance();
    mOverflingDistance = configuration.getScaledOverflingDistance();
    mDensityScale = getContext().getResources().getDisplayMetrics().density;
    setPersistentDrawingCache(ViewGroup.PERSISTENT_ANIMATION_CACHE | ViewGroup.PERSISTENT_SCROLLING_CACHE);
}
Also used : ViewConfiguration(android.view.ViewConfiguration)

Example 42 with ViewConfiguration

use of android.view.ViewConfiguration in project android_frameworks_base by crdroidandroid.

the class StackView method initStackView.

private void initStackView() {
    configureViewAnimator(NUM_ACTIVE_VIEWS, 1);
    setStaticTransformationsEnabled(true);
    final ViewConfiguration configuration = ViewConfiguration.get(getContext());
    mTouchSlop = configuration.getScaledTouchSlop();
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
    mActivePointerId = INVALID_POINTER;
    mHighlight = new ImageView(getContext());
    mHighlight.setLayoutParams(new LayoutParams(mHighlight));
    addViewInLayout(mHighlight, -1, new LayoutParams(mHighlight));
    mClickFeedback = new ImageView(getContext());
    mClickFeedback.setLayoutParams(new LayoutParams(mClickFeedback));
    addViewInLayout(mClickFeedback, -1, new LayoutParams(mClickFeedback));
    mClickFeedback.setVisibility(INVISIBLE);
    mStackSlider = new StackSlider();
    if (sHolographicHelper == null) {
        sHolographicHelper = new HolographicHelper(mContext);
    }
    setClipChildren(false);
    setClipToPadding(false);
    // This sets the form of the StackView, which is currently to have the perspective-shifted
    // views above the active view, and have items slide down when sliding out. The opposite is
    // available by using ITEMS_SLIDE_UP.
    mStackMode = ITEMS_SLIDE_DOWN;
    // This is a flag to indicate the the stack is loading for the first time
    mWhichChild = -1;
    // Adjust the frame padding based on the density, since the highlight changes based
    // on the density
    final float density = mContext.getResources().getDisplayMetrics().density;
    mFramePadding = (int) Math.ceil(density * FRAME_PADDING);
}
Also used : ViewConfiguration(android.view.ViewConfiguration)

Example 43 with ViewConfiguration

use of android.view.ViewConfiguration in project android_frameworks_base by crdroidandroid.

the class SwipeDismissLayout method init.

private void init(Context context) {
    ViewConfiguration vc = ViewConfiguration.get(context);
    mSlop = vc.getScaledTouchSlop();
    mMinFlingVelocity = vc.getScaledMinimumFlingVelocity();
    TypedArray a = context.getTheme().obtainStyledAttributes(com.android.internal.R.styleable.Theme);
    mIsWindowNativelyTranslucent = a.getBoolean(com.android.internal.R.styleable.Window_windowIsTranslucent, false);
    a.recycle();
}
Also used : ViewConfiguration(android.view.ViewConfiguration) TypedArray(android.content.res.TypedArray)

Example 44 with ViewConfiguration

use of android.view.ViewConfiguration in project android_frameworks_base by crdroidandroid.

the class CropView method onTouchEvent.

@Override
public boolean onTouchEvent(MotionEvent event) {
    int action = event.getActionMasked();
    final boolean pointerUp = action == MotionEvent.ACTION_POINTER_UP;
    final int skipIndex = pointerUp ? event.getActionIndex() : -1;
    // Determine focal point
    float sumX = 0, sumY = 0;
    final int count = event.getPointerCount();
    for (int i = 0; i < count; i++) {
        if (skipIndex == i)
            continue;
        sumX += event.getX(i);
        sumY += event.getY(i);
    }
    final int div = pointerUp ? count - 1 : count;
    float x = sumX / div;
    float y = sumY / div;
    if (action == MotionEvent.ACTION_DOWN) {
        mFirstX = x;
        mFirstY = y;
        mTouchDownTime = System.currentTimeMillis();
        if (mTouchCallback != null) {
            mTouchCallback.onTouchDown();
        }
    } else if (action == MotionEvent.ACTION_UP) {
        ViewConfiguration config = ViewConfiguration.get(getContext());
        float squaredDist = (mFirstX - x) * (mFirstX - x) + (mFirstY - y) * (mFirstY - y);
        float slop = config.getScaledTouchSlop() * config.getScaledTouchSlop();
        long now = System.currentTimeMillis();
        if (mTouchCallback != null) {
            // only do this if it's a small movement
            if (squaredDist < slop && now < mTouchDownTime + ViewConfiguration.getTapTimeout()) {
                mTouchCallback.onTap();
            }
            mTouchCallback.onTouchUp();
        }
    }
    if (!mTouchEnabled) {
        return true;
    }
    synchronized (mLock) {
        mScaleGestureDetector.onTouchEvent(event);
        switch(action) {
            case MotionEvent.ACTION_MOVE:
                float[] point = mTempPoint;
                point[0] = (mLastX - x) / mRenderer.scale;
                point[1] = (mLastY - y) / mRenderer.scale;
                mInverseRotateMatrix.mapPoints(point);
                mCenterX += point[0];
                mCenterY += point[1];
                updateCenter();
                invalidate();
                break;
        }
        if (mRenderer.source != null) {
            // Adjust position so that the wallpaper covers the entire area
            // of the screen
            final RectF edges = mTempEdges;
            getEdgesHelper(edges);
            final float scale = mRenderer.scale;
            float[] coef = mTempCoef;
            coef[0] = 1;
            coef[1] = 1;
            mRotateMatrix.mapPoints(coef);
            float[] adjustment = mTempAdjustment;
            mTempAdjustment[0] = 0;
            mTempAdjustment[1] = 0;
            if (edges.left > 0) {
                adjustment[0] = edges.left / scale;
            } else if (edges.right < getWidth()) {
                adjustment[0] = (edges.right - getWidth()) / scale;
            }
            if (edges.top > 0) {
                adjustment[1] = (float) Math.ceil(edges.top / scale);
            } else if (edges.bottom < getHeight()) {
                adjustment[1] = (edges.bottom - getHeight()) / scale;
            }
            for (int dim = 0; dim <= 1; dim++) {
                if (coef[dim] > 0)
                    adjustment[dim] = (float) Math.ceil(adjustment[dim]);
            }
            mInverseRotateMatrix.mapPoints(adjustment);
            mCenterX += adjustment[0];
            mCenterY += adjustment[1];
            updateCenter();
        }
    }
    mLastX = x;
    mLastY = y;
    return true;
}
Also used : RectF(android.graphics.RectF) ViewConfiguration(android.view.ViewConfiguration) Point(android.graphics.Point)

Example 45 with ViewConfiguration

use of android.view.ViewConfiguration in project android_frameworks_base by crdroidandroid.

the class NotificationStackScrollLayout method initView.

private void initView(Context context) {
    mScroller = new OverScroller(getContext());
    setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
    setClipChildren(false);
    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = configuration.getScaledTouchSlop();
    mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
    mOverflingDistance = configuration.getScaledOverflingDistance();
    mCollapsedSize = context.getResources().getDimensionPixelSize(R.dimen.notification_min_height);
    mBottomStackPeekSize = context.getResources().getDimensionPixelSize(R.dimen.bottom_stack_peek_amount);
    mStackScrollAlgorithm.initView(context);
    mPaddingBetweenElements = Math.max(1, context.getResources().getDimensionPixelSize(R.dimen.notification_divider_height));
    mIncreasedPaddingBetweenElements = context.getResources().getDimensionPixelSize(R.dimen.notification_divider_height_increased);
    mBottomStackSlowDownHeight = mStackScrollAlgorithm.getBottomStackSlowDownLength();
    mMinTopOverScrollToEscape = getResources().getDimensionPixelSize(R.dimen.min_top_overscroll_to_qs);
}
Also used : ViewConfiguration(android.view.ViewConfiguration) OverScroller(android.widget.OverScroller)

Aggregations

ViewConfiguration (android.view.ViewConfiguration)234 Scroller (android.widget.Scroller)53 Context (android.content.Context)36 TypedArray (android.content.res.TypedArray)29 Field (java.lang.reflect.Field)20 EdgeEffectCompat (android.support.v4.widget.EdgeEffectCompat)18 View (android.view.View)15 Point (android.graphics.Point)14 OverScroller (android.widget.OverScroller)12 Drawable (android.graphics.drawable.Drawable)10 Paint (android.graphics.Paint)8 DisplayMetrics (android.util.DisplayMetrics)8 Resources (android.content.res.Resources)7 RectF (android.graphics.RectF)7 GestureDetector (android.view.GestureDetector)7 ImageView (android.widget.ImageView)6 PointF (android.graphics.PointF)5 FlingAnimationUtils (com.android.systemui.statusbar.FlingAnimationUtils)5 Rect (android.graphics.Rect)4 SlidingTabLayout (com.google.samples.apps.iosched.ui.widget.SlidingTabLayout)4