Java Code Examples for android.view.ViewConfiguration#getTapTimeout()
The following examples show how to use
android.view.ViewConfiguration#getTapTimeout() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FTouchHelper.java From switchbutton with MIT License | 6 votes |
/** * 是否是点击事件 * * @param event * @param context * @return */ public boolean isClick(MotionEvent event, Context context) { if (event.getAction() == MotionEvent.ACTION_UP) { final long clickTimeout = ViewConfiguration.getPressedStateDuration() + ViewConfiguration.getTapTimeout(); final int touchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); final long duration = event.getEventTime() - event.getDownTime(); final int dx = (int) getDeltaXFromDown(); final int dy = (int) getDeltaYFromDown(); if (duration < clickTimeout && dx < touchSlop && dy < touchSlop) return true; } return false; }
Example 2
Source File: SwitchButton.java From UltimateAndroid with Apache License 2.0 | 5 votes |
private void initView() { mConf = Configuration.getDefault(getContext().getResources().getDisplayMetrics().density); mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop(); mClickTimeout = ViewConfiguration.getPressedStateDuration() + ViewConfiguration.getTapTimeout(); mAnimationController = AnimationController.getDefault().init(mOnAnimateListener); mBounds = new Rect(); if (SHOW_RECT) { mRectPaint = new Paint(); mRectPaint.setStyle(Style.STROKE); } }
Example 3
Source File: OperableView.java From pandora with Apache License 2.0 | 5 votes |
public OperableView(Context context) { super(context); ViewConfiguration vc = ViewConfiguration.get(context); touchSlop = vc.getScaledTouchSlop(); longPressTimeout = ViewConfiguration.getLongPressTimeout(); tapTimeout = ViewConfiguration.getTapTimeout(); selectCanvas = new SelectCanvas(this); relativeCanvas = new RelativeCanvas(this); gridCanvas = new GridCanvas(this); clickInfoCanvas = new ClickInfoCanvas(this); }
Example 4
Source File: DeleteView.java From budget-envelopes with GNU General Public License v3.0 | 5 votes |
private void init(Context cntx) { mInnerView = null; mSwipeStart = -1; mSwipeStartTime = -1; mBackground = 0; ViewConfiguration config = ViewConfiguration.get(cntx); mTouchSlop = config.getScaledTouchSlop(); mFlingSlop = config.getScaledMinimumFlingVelocity(); mFlingCap = config.getScaledMaximumFlingVelocity(); mPressTimeout = config.getTapTimeout(); mPressRunnable = new Runnable() { public void run() { if (mSwipeState == STATE_PRESSED) { mInnerView.setPressed(true); } } }; mLongPressTimeout = mPressTimeout + config.getLongPressTimeout(); mLongPressRunnable = new Runnable() { public void run() { if (mSwipeState == STATE_PRESSED) { performLongClick(); mInnerView.setPressed(false); } } }; mUnpressRunnable = new Runnable() { public void run() { mInnerView.setPressed(false); } }; mSwipeState = STATE_READY; mVelocityTracker = null; mAnim = null; mChecked = false; mListener = null; setClickable(true); }
Example 5
Source File: SwitchButton.java From BlunoAccessoryShieldDemo with GNU General Public License v3.0 | 5 votes |
private void initView(Context context) { mPaint = new Paint(); mPaint.setColor(Color.WHITE); Resources resources = context.getResources(); // get viewConfiguration mClickTimeout = ViewConfiguration.getPressedStateDuration() + ViewConfiguration.getTapTimeout(); mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); // get Bitmap mBottom = BitmapFactory.decodeResource(resources, R.drawable.bottom); mBtnPressed = BitmapFactory.decodeResource(resources, R.drawable.btn_pressed); mBtnNormal = BitmapFactory.decodeResource(resources, R.drawable.btn_unpressed); mFrame = BitmapFactory.decodeResource(resources, R.drawable.frame); mMask = BitmapFactory.decodeResource(resources, R.drawable.mask); mCurBtnPic = mBtnNormal; mBtnWidth = mBtnPressed.getWidth(); mMaskWidth = mMask.getWidth(); mMaskHeight = mMask.getHeight(); mBtnOffPos = mBtnWidth / 2; mBtnOnPos = mMaskWidth - mBtnWidth / 2; mBtnPos = mChecked ? mBtnOnPos : mBtnOffPos; mRealPos = getRealPos(mBtnPos); final float density = getResources().getDisplayMetrics().density; mVelocity = (int) (VELOCITY * density + 0.5f); mExtendOffsetY = (int) (EXTENDED_OFFSET_Y * density + 0.5f); mSaveLayerRectF = new RectF(0, mExtendOffsetY, mMask.getWidth(), mMask.getHeight() + mExtendOffsetY); mXfermode = new PorterDuffXfermode(PorterDuff.Mode.SRC_IN); }
Example 6
Source File: ListPopupWindow.java From MDPreference with Apache License 2.0 | 5 votes |
public ForwardingListener(View src) { mSrc = src; mScaledTouchSlop = ViewConfiguration.get(src.getContext()).getScaledTouchSlop(); mTapTimeout = ViewConfiguration.getTapTimeout(); // Use a medium-press timeout. Halfway between tap and long-press. mLongPressTimeout = (mTapTimeout + ViewConfiguration.getLongPressTimeout()) / 2; }
Example 7
Source File: SwitchButton.java From BaseProject with Apache License 2.0 | 5 votes |
private void initView(Context context) { mPaint = new Paint(); mPaint.setColor(Color.WHITE); Resources resources = context.getResources(); // get viewConfiguration mClickTimeout = ViewConfiguration.getPressedStateDuration() + ViewConfiguration.getTapTimeout(); mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); // get Bitmap mBottom = BitmapFactory.decodeResource(resources, R.drawable.switch_btn_bottom); mBtnPressed = BitmapFactory.decodeResource(resources, R.drawable.switch_btn_pressed); mBtnNormal = BitmapFactory.decodeResource(resources, R.drawable.swithc_btn_unpressed); mFrame = BitmapFactory.decodeResource(resources, R.drawable.switch_btn_frame); mMask = BitmapFactory.decodeResource(resources, R.drawable.switch_btn_mask); mCurBtnPic = mBtnNormal; mBtnWidth = mBtnPressed.getWidth(); mMaskWidth = mMask.getWidth(); mMaskHeight = mMask.getHeight(); mBtnOffPos = mBtnWidth / 2; mBtnOnPos = mMaskWidth - mBtnWidth / 2; mBtnPos = mChecked ? mBtnOnPos : mBtnOffPos; mRealPos = getRealPos(mBtnPos); final float density = getResources().getDisplayMetrics().density; mVelocity = (int) (VELOCITY * density + 0.5f); mExtendOffsetY = (int) (EXTENDED_OFFSET_Y * density + 0.5f); mSaveLayerRectF = new RectF(0, mExtendOffsetY, mMask.getWidth(), mMask.getHeight() + mExtendOffsetY); mXfermode = new PorterDuffXfermode(PorterDuff.Mode.SRC_IN); }
Example 8
Source File: AppMenuDragHelper.java From AndroidChromium with Apache License 2.0 | 5 votes |
AppMenuDragHelper(Activity activity, AppMenu appMenu, int itemRowHeight) { mActivity = activity; mAppMenu = appMenu; mItemRowHeight = itemRowHeight; Resources res = mActivity.getResources(); mAutoScrollFullVelocity = res.getDimensionPixelSize(R.dimen.auto_scroll_full_velocity); // If user is dragging and the popup ListView is too big to display at once, // mDragScrolling animator scrolls mPopup.getListView() automatically depending on // the user's touch position. mDragScrolling.setTimeListener(new TimeAnimator.TimeListener() { @Override public void onTimeUpdate(TimeAnimator animation, long totalTime, long deltaTime) { ListPopupWindow popup = mAppMenu.getPopup(); if (popup == null || popup.getListView() == null) return; // We keep both mDragScrollOffset and mDragScrollOffsetRounded because // the actual scrolling is by the rounded value but at the same time we also // want to keep the precise scroll value in float. mDragScrollOffset += (deltaTime * 0.001f) * mDragScrollingVelocity; int diff = Math.round(mDragScrollOffset - mDragScrollOffsetRounded); mDragScrollOffsetRounded += diff; popup.getListView().smoothScrollBy(diff, 0); // Force touch move event to highlight items correctly for the scrolled position. if (!Float.isNaN(mLastTouchX) && !Float.isNaN(mLastTouchY)) { menuItemAction(Math.round(mLastTouchX), Math.round(mLastTouchY), ITEM_ACTION_HIGHLIGHT); } } }); // We use medium timeout, the average of tap and long press timeouts. This is consistent // with ListPopupWindow#ForwardingListener implementation. mTapTimeout = (ViewConfiguration.getTapTimeout() + ViewConfiguration.getLongPressTimeout()) / 2; mScaledTouchSlop = ViewConfiguration.get(activity).getScaledTouchSlop(); }
Example 9
Source File: RadialPickerLayout.java From Conquer with Apache License 2.0 | 4 votes |
public RadialPickerLayout(Context context, AttributeSet attrs) { super(context, attrs); setOnTouchListener(this); ViewConfiguration vc = ViewConfiguration.get(context); TOUCH_SLOP = vc.getScaledTouchSlop(); TAP_TIMEOUT = ViewConfiguration.getTapTimeout(); mDoingMove = false; mCircleView = new CircleView(context); addView(mCircleView); mAmPmCirclesView = new AmPmCirclesView(context); addView(mAmPmCirclesView); mHourRadialTextsView = new RadialTextsView(context); addView(mHourRadialTextsView); mMinuteRadialTextsView = new RadialTextsView(context); addView(mMinuteRadialTextsView); mHourRadialSelectorView = new RadialSelectorView(context); addView(mHourRadialSelectorView); mMinuteRadialSelectorView = new RadialSelectorView(context); addView(mMinuteRadialSelectorView); // Prepare mapping to snap touchable degrees to selectable degrees. preparePrefer30sMap(); mVibrator = (Vibrator) context.getSystemService(Service.VIBRATOR_SERVICE); mLastVibrate = 0; mLastValueSelected = -1; mInputEnabled = true; mGrayBox = new View(context); mGrayBox.setLayoutParams(new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); mGrayBox.setBackgroundColor(getResources().getColor(R.color.transparent_black)); mGrayBox.setVisibility(View.INVISIBLE); addView(mGrayBox); mAccessibilityManager = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE); mTimeInitialized = false; }
Example 10
Source File: RadialPickerLayout.java From date_picker_converter with Apache License 2.0 | 4 votes |
public RadialPickerLayout(Context context, AttributeSet attrs) { super(context, attrs); setOnTouchListener(this); ViewConfiguration vc = ViewConfiguration.get(context); TOUCH_SLOP = vc.getScaledTouchSlop(); TAP_TIMEOUT = ViewConfiguration.getTapTimeout(); mDoingMove = false; mCircleView = new CircleView(context); addView(mCircleView); mAmPmCirclesView = new AmPmCirclesView(context); addView(mAmPmCirclesView); mHourRadialSelectorView = new RadialSelectorView(context); addView(mHourRadialSelectorView); mMinuteRadialSelectorView = new RadialSelectorView(context); addView(mMinuteRadialSelectorView); mSecondRadialSelectorView = new RadialSelectorView(context); addView(mSecondRadialSelectorView); mHourRadialTextsView = new RadialTextsView(context); addView(mHourRadialTextsView); mMinuteRadialTextsView = new RadialTextsView(context); addView(mMinuteRadialTextsView); mSecondRadialTextsView = new RadialTextsView(context); addView(mSecondRadialTextsView); // Prepare mapping to snap touchable degrees to selectable degrees. preparePrefer30sMap(); mLastValueSelected = null; mInputEnabled = true; mGrayBox = new View(context); mGrayBox.setLayoutParams(new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); mGrayBox.setBackgroundColor(ContextCompat.getColor(context, R.color.mdtp_transparent_black)); mGrayBox.setVisibility(View.INVISIBLE); addView(mGrayBox); mAccessibilityManager = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE); mTimeInitialized = false; }
Example 11
Source File: RadialPickerLayout.java From Blackbulb with GNU General Public License v3.0 | 4 votes |
public RadialPickerLayout(Context context, AttributeSet attrs) { super(context, attrs); setOnTouchListener(this); ViewConfiguration vc = ViewConfiguration.get(context); TOUCH_SLOP = vc.getScaledTouchSlop(); TAP_TIMEOUT = ViewConfiguration.getTapTimeout(); mDoingMove = false; mCircleView = new CircleView(context); addView(mCircleView); mAmPmCirclesView = new AmPmCirclesView(context); addView(mAmPmCirclesView); mHourRadialSelectorView = new RadialSelectorView(context); addView(mHourRadialSelectorView); mMinuteRadialSelectorView = new RadialSelectorView(context); addView(mMinuteRadialSelectorView); mSecondRadialSelectorView = new RadialSelectorView(context); addView(mSecondRadialSelectorView); mHourRadialTextsView = new RadialTextsView(context); addView(mHourRadialTextsView); mMinuteRadialTextsView = new RadialTextsView(context); addView(mMinuteRadialTextsView); mSecondRadialTextsView = new RadialTextsView(context); addView(mSecondRadialTextsView); // Prepare mapping to snap touchable degrees to selectable degrees. preparePrefer30sMap(); mLastValueSelected = null; mInputEnabled = true; mGrayBox = new View(context); mGrayBox.setLayoutParams(new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); mGrayBox.setBackgroundColor(context.getResources().getColor(R.color.mdtp_transparent_black)); mGrayBox.setVisibility(View.INVISIBLE); addView(mGrayBox); mAccessibilityManager = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE); mTimeInitialized = false; }
Example 12
Source File: ArbitraryTapListener.java From under-the-hood with Apache License 2.0 | 4 votes |
@Override public boolean onTouch(View v, MotionEvent event) { if (onClickListener == null) { return false; } boolean consume = false; switch (event.getAction()) { case MotionEvent.ACTION_DOWN: Log.d(TAG, "down"); touchDownMs = System.currentTimeMillis(); break; case MotionEvent.ACTION_UP: Log.d(TAG, "up"); if ((System.currentTimeMillis() - touchDownMs) > ViewConfiguration.getTapTimeout()) { //it was not a tap numberOfTaps = 0; lastTapTimeMs = 0; Log.d(TAG, "reset"); break; } if (numberOfTaps > 0 && (System.currentTimeMillis() - lastTapTimeMs) < ViewConfiguration.getDoubleTapTimeout()) { numberOfTaps += 1; Log.d(TAG, "+1"); consume = true; } else { Log.d(TAG, "1"); numberOfTaps = 1; } lastTapTimeMs = System.currentTimeMillis(); if (numberOfTaps >= targetNumberOfTaps) { Log.d(TAG, "goal"); onClickListener.onClick(v); numberOfTaps = 0; lastTapTimeMs = 0; consume = true; } } return consume; }
Example 13
Source File: HandleView.java From android-chromium with BSD 2-Clause "Simplified" License | 4 votes |
@Override public boolean onTouchEvent(MotionEvent ev) { switch (ev.getActionMasked()) { case MotionEvent.ACTION_DOWN: { mDownPositionX = ev.getRawX(); mDownPositionY = ev.getRawY(); mTouchToWindowOffsetX = mDownPositionX - mPositionX; mTouchToWindowOffsetY = mDownPositionY - mPositionY; mIsDragging = true; mController.beforeStartUpdatingPosition(this); mTouchTimer = SystemClock.uptimeMillis(); break; } case MotionEvent.ACTION_MOVE: { updatePosition(ev.getRawX(), ev.getRawY()); break; } case MotionEvent.ACTION_UP: if (mIsInsertionHandle) { long delay = SystemClock.uptimeMillis() - mTouchTimer; if (delay < ViewConfiguration.getTapTimeout()) { if (mPastePopupWindow != null && mPastePopupWindow.isShowing()) { // Tapping on the handle dismisses the displayed paste view, mPastePopupWindow.hide(); } else { showPastePopupWindow(); } } } mIsDragging = false; break; case MotionEvent.ACTION_CANCEL: mIsDragging = false; break; default: return false; } return true; }
Example 14
Source File: RadialPickerLayout.java From AlarmOn with Apache License 2.0 | 4 votes |
public RadialPickerLayout(Context context, AttributeSet attrs) { super(context, attrs); setOnTouchListener(this); ViewConfiguration vc = ViewConfiguration.get(context); TOUCH_SLOP = vc.getScaledTouchSlop(); TAP_TIMEOUT = ViewConfiguration.getTapTimeout(); mDoingMove = false; mCircleView = new CircleView(context); addView(mCircleView); mAmPmCirclesView = new AmPmCirclesView(context); addView(mAmPmCirclesView); mHourRadialSelectorView = new RadialSelectorView(context); addView(mHourRadialSelectorView); mMinuteRadialSelectorView = new RadialSelectorView(context); addView(mMinuteRadialSelectorView); mSecondRadialSelectorView = new RadialSelectorView(context); addView(mSecondRadialSelectorView); mHourRadialTextsView = new RadialTextsView(context); addView(mHourRadialTextsView); mMinuteRadialTextsView = new RadialTextsView(context); addView(mMinuteRadialTextsView); mSecondRadialTextsView = new RadialTextsView(context); addView(mSecondRadialTextsView); // Prepare mapping to snap touchable degrees to selectable degrees. preparePrefer30sMap(); mLastValueSelected = null; mInputEnabled = true; mGrayBox = new View(context); mGrayBox.setLayoutParams(new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); mGrayBox.setBackgroundColor(ContextCompat.getColor(context, R.color.mdtp_transparent_black)); mGrayBox.setVisibility(View.INVISIBLE); addView(mGrayBox); mAccessibilityManager = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE); mTimeInitialized = false; }
Example 15
Source File: MotionEvents.java From android-test with Apache License 2.0 | 4 votes |
public static DownResultHolder sendDown( UiController uiController, float[] coordinates, float[] precision, int inputDevice, int buttonState) { checkNotNull(uiController); checkNotNull(coordinates); checkNotNull(precision); for (int retry = 0; retry < MAX_CLICK_ATTEMPTS; retry++) { MotionEvent motionEvent = null; try { motionEvent = obtainDownEvent(coordinates, precision, inputDevice, buttonState); // The down event should be considered a tap if it is long enough to be detected // but short enough not to be a long-press. Assume that TapTimeout is set at least // twice the detection time for a tap (no need to sleep for the whole TapTimeout since // we aren't concerned about scrolling here). long downTime = motionEvent.getDownTime(); long isTapAt = downTime + (ViewConfiguration.getTapTimeout() / 2); boolean injectEventSucceeded = uiController.injectMotionEvent(motionEvent); while (true) { long delayToBeTap = isTapAt - SystemClock.uptimeMillis(); if (delayToBeTap <= 10) { break; } // Sleep only a fraction of the time, since there may be other events in the UI queue // that could cause us to start sleeping late, and then oversleep. uiController.loopMainThreadForAtLeast(delayToBeTap / 4); } boolean longPress = false; if (SystemClock.uptimeMillis() > (downTime + ViewConfiguration.getLongPressTimeout())) { longPress = true; Log.w(TAG, "Overslept and turned a tap into a long press"); } if (!injectEventSucceeded) { motionEvent.recycle(); motionEvent = null; continue; } return new DownResultHolder(motionEvent, longPress); } catch (InjectEventSecurityException e) { throw new PerformException.Builder() .withActionDescription("Send down motion event") .withViewDescription("unknown") // likely to be replaced by FailureHandler .withCause(e) .build(); } } throw new PerformException.Builder() .withActionDescription( String.format(Locale.ROOT, "click (after %s attempts)", MAX_CLICK_ATTEMPTS)) .withViewDescription("unknown") // likely to be replaced by FailureHandler .build(); }
Example 16
Source File: RadialPickerLayout.java From narrate-android with Apache License 2.0 | 4 votes |
public RadialPickerLayout(Context context, AttributeSet attrs) { super(context, attrs); setOnTouchListener(this); ViewConfiguration vc = ViewConfiguration.get(context); TOUCH_SLOP = vc.getScaledTouchSlop(); TAP_TIMEOUT = ViewConfiguration.getTapTimeout(); mDoingMove = false; mCircleView = new CircleView(context); addView(mCircleView); mAmPmCirclesView = new AmPmCirclesView(context); addView(mAmPmCirclesView); mHourRadialTextsView = new RadialTextsView(context); addView(mHourRadialTextsView); mMinuteRadialTextsView = new RadialTextsView(context); addView(mMinuteRadialTextsView); mHourRadialSelectorView = new RadialSelectorView(context); addView(mHourRadialSelectorView); mMinuteRadialSelectorView = new RadialSelectorView(context); addView(mMinuteRadialSelectorView); // Prepare mapping to snap touchable degrees to selectable degrees. preparePrefer30sMap(); mLastValueSelected = -1; mInputEnabled = true; mGrayBox = new View(context); mGrayBox.setLayoutParams(new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); mGrayBox.setBackgroundColor(getResources().getColor(R.color.transparent_black)); mGrayBox.setVisibility(View.INVISIBLE); addView(mGrayBox); mAccessibilityManager = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE); mTimeInitialized = false; }
Example 17
Source File: RadialPickerLayout.java From StyleableDateTimePicker with MIT License | 4 votes |
public RadialPickerLayout(Context context, AttributeSet attrs) { super(context, attrs); setOnTouchListener(this); ViewConfiguration vc = ViewConfiguration.get(context); TOUCH_SLOP = vc.getScaledTouchSlop(); TAP_TIMEOUT = ViewConfiguration.getTapTimeout(); mDoingMove = false; mCircleView = new CircleView(context); addView(mCircleView); mAmPmCirclesView = new AmPmCirclesView(context); addView(mAmPmCirclesView); mHourRadialTextsView = new RadialTextsView(context); addView(mHourRadialTextsView); mMinuteRadialTextsView = new RadialTextsView(context); addView(mMinuteRadialTextsView); mHourRadialSelectorView = new RadialSelectorView(context); addView(mHourRadialSelectorView); mMinuteRadialSelectorView = new RadialSelectorView(context); addView(mMinuteRadialSelectorView); // Prepare mapping to snap touchable degrees to selectable degrees. preparePrefer30sMap(); mLastValueSelected = -1; mInputEnabled = true; mGrayBox = new View(context); mGrayBox.setLayoutParams(new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); mGrayBox.setBackgroundColor(getResources().getColor(R.color.transparent_black)); mGrayBox.setVisibility(View.INVISIBLE); addView(mGrayBox); mAccessibilityManager = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE); mTimeInitialized = false; }
Example 18
Source File: ViewConfigurationHelper.java From 365browser with Apache License 2.0 | 4 votes |
@CalledByNative private static int getTapTimeout() { return ViewConfiguration.getTapTimeout(); }
Example 19
Source File: PersianRadialPickerLayout.java From PersianDateRangePicker with Apache License 2.0 | 4 votes |
public PersianRadialPickerLayout(Context context, AttributeSet attrs) { super(context, attrs); setOnTouchListener(this); ViewConfiguration vc = ViewConfiguration.get(context); TOUCH_SLOP = vc.getScaledTouchSlop(); TAP_TIMEOUT = ViewConfiguration.getTapTimeout(); mDoingMove = false; mCircleView = new CircleView(context); addView(mCircleView); mAmPmCirclesView = new AmPmCirclesView(context, fontName); addView(mAmPmCirclesView); mHourRadialSelectorView = new RadialSelectorView(context); addView(mHourRadialSelectorView); mMinuteRadialSelectorView = new RadialSelectorView(context); addView(mMinuteRadialSelectorView); mHourRadialTextsView = new RadialTextsView(context, fontName); addView(mHourRadialTextsView); mMinuteRadialTextsView = new RadialTextsView(context, fontName); addView(mMinuteRadialTextsView); // Prepare mapping to snap touchable degrees to selectable degrees. preparePrefer30sMap(); mLastValueSelected = -1; mInputEnabled = true; mGrayBox = new View(context); mGrayBox.setLayoutParams(new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); mGrayBox.setBackgroundColor(getResources().getColor(R.color.mdtp_transparent_black)); mGrayBox.setVisibility(View.INVISIBLE); addView(mGrayBox); mAccessibilityManager = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE); mTimeInitialized = false; }
Example 20
Source File: GestureUtils.java From talkback with Apache License 2.0 | 3 votes |
/** * Create a description for a tap gesture. Gestures outside the screen will be offset to fit in * the screen. * * @param context The context in which the gesture is being created * @param x The x coordinate of the tap * @param y The y coordinate of the tap * @return A description of a tap at ({@code x}, {@code y}) */ public static GestureDescription createTap(Context context, int x, int y) { Path path = new Path(); path.moveTo(x, y); int durationMs = ViewConfiguration.getTapTimeout(); return createGestureDescription(new StrokeDescription(path, 0, durationMs)); }