Example usage for android.view HapticFeedbackConstants VIRTUAL_KEY

List of usage examples for android.view HapticFeedbackConstants VIRTUAL_KEY

Introduction

In this page you can find the example usage for android.view HapticFeedbackConstants VIRTUAL_KEY.

Prototype

int VIRTUAL_KEY

To view the source code for android.view HapticFeedbackConstants VIRTUAL_KEY.

Click Source Link

Document

The user has pressed on a virtual on-screen key.

Usage

From source file:com.android.soma.Launcher.java

/**
 * Event handler for the voice button/*ww  w .  j a  v  a 2s .c  o m*/
 *
 * @param v The view that was clicked.
 */
public void onClickVoiceButton(View v) {
    v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);

    startVoice();
}

From source file:com.android.soma.Launcher.java

public void performHapticFeedbackOnTouchDown(View v) {
    // Provide the same haptic feedback that the system offers for virtual keys.
    v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
}

From source file:com.android.launcher3.Launcher.java

public View.OnTouchListener getHapticFeedbackTouchListener() {
    if (mHapticFeedbackTouchListener == null) {
        mHapticFeedbackTouchListener = new View.OnTouchListener() {
            @SuppressLint("ClickableViewAccessibility")
            @Override/* ww  w  . j a va 2s.c  om*/
            public boolean onTouch(View v, MotionEvent event) {
                if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_DOWN) {
                    v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
                }
                return false;
            }
        };
    }
    return mHapticFeedbackTouchListener;
}

From source file:com.klinker.android.launcher.launcher3.Launcher.java

private void createClickableSearch() {
    new Handler().postDelayed(new Runnable() {
        @Override//from w  w  w .j  ava  2s.co  m
        public void run() {
            FrameLayout content = (FrameLayout) findViewById(R.id.search_dummy);

            View search = new View(Launcher.this);

            FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                    mQsb.getHeight());
            params.topMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 28,
                    getResources().getDisplayMetrics());

            search.setLayoutParams(params);

            search.setOnTouchListener(new View.OnTouchListener() {
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    if (!disableSearch()) {
                        if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_DOWN) {
                            v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
                        }
                    }

                    return disableSearch();
                }
            });
            search.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    startSearch("", false, new Bundle(), new Rect());
                }
            });

            content.addView(search);
        }
    }, 1000);

}

From source file:xyz.klinker.blur.launcher3.Launcher.java

private void createClickableSearch(final int tryNumber) {
    new Handler().postDelayed(new Runnable() {
        @Override//from  w  w w  .  ja va  2 s  . c  om
        public void run() {
            FrameLayout content = (FrameLayout) findViewById(R.id.search_dummy);

            View search = new View(Launcher.this);

            FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                    mQsb.getHeight());
            params.topMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 28,
                    getResources().getDisplayMetrics());

            search.setLayoutParams(params);

            search.setOnTouchListener(new View.OnTouchListener() {
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    if (!disableSearch()) {
                        if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_DOWN) {
                            v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
                        }
                    }

                    return disableSearch();
                }
            });
            search.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    showGlobalSearchOverlay();
                    //startSearch("", false, new Bundle(), new Rect());
                }
            });

            try {
                content.addView(search);
            } catch (Exception e) {
                if (tryNumber <= 3) {
                    new Handler().postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            createClickableSearch(tryNumber + 1);
                        }
                    }, 2000);
                }
            }
        }
    }, 1000);

}