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:de.uni.stuttgart.informatik.ToureNPlaner.UI.Activities.MapScreen.MapScreen.java

@Override
public void onChange(final Session.Change change) {
    runOnUiThread(new Runnable() {

        @Override//from w  w w.j av  a 2  s.co  m
        public void run() {
            if (change.isResultChange()) {
                if (session.getResult() == null) {
                    addPathToMap(null);
                    ((TextView) findViewById(R.id.overlay)).setText("");
                } else {
                    updateDistancePopup();
                    addPathToMap(session.getResult().getWay());
                    String msg = session.getResult().getMisc().getMessage();
                    if (msg != null && !msg.equals("")) {
                        if (messageToast != null)
                            messageToast.cancel();
                        messageToast = Toast.makeText(MapScreen.this, msg, Toast.LENGTH_LONG);
                        messageToast.show();
                    }
                }
            }
            if (change.isDndChange() && instantRequest == MapScreenPreferences.Instant.ALWAYS) {
                performRequest(false);
            }
            if (change.isModelChange()) {
                if (!change.isAddChange()) {
                    Edit edit = new SetResultEdit(session, null);
                    edit.perform();
                } else {
                    // Important! Try to perform the NNS Search before, notifying any one else about the change.
                    // else through HTTP pipelining the NNS might be performed after the request!
                    performNNSearch(change.getNode());
                    mapView.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
                }
                if (instantRequest != MapScreenPreferences.Instant.NEVER) {
                    performRequest(true);
                }
            }
        }
    });
}

From source file:com.achep.acdisplay.ui.fragments.AcDisplayFragment.java

/**
 * @see #showWidget(com.achep.acdisplay.ui.components.Widget)
 *///w ww . ja  v a 2 s .co  m
protected void showWidget(@NonNull Widget widget, boolean animate) {
    mHandler.removeMessages(MSG_SHOW_HOME_WIDGET);
    mHasPinnedWidget = false;

    Log.d(TAG, "showing widget " + widget);

    View iconView;

    if (mSelectedWidget != null) {
        iconView = mSelectedWidget.getIconView();
        if (iconView != null) {
            iconView.setSelected(false);
        }

        mSelectedWidget.onViewDetached();
    }

    mSelectedWidget = widget;
    resetSceneContainerParams();
    animate &= isAnimatableAuto();

    SceneCompat scene = findSceneByWidget(mSelectedWidget);
    if (scene == null)
        scene = mSceneMainClock;
    if (mCurrentScene != scene) {
        goScene(scene, animate);
    } else if (animate) {
        final ViewGroup viewGroup = mSelectedWidget.getView();
        maybeBeginDelayedTransition(viewGroup, mTransitionJit);
    }

    mSelectedWidget.onViewAttached();
    mBackground.dispatchSetBackground(mSelectedWidget.getBackground(), mSelectedWidget.getBackgroundMask());
    updateStatusClockVisibility(!mSelectedWidget.hasClock() && getConfig().isFullScreen());

    iconView = mSelectedWidget.getIconView();
    if (iconView != null) {
        iconView.setSelected(true);
        iconView.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
    }

    if (!isResumed()) {
        return;
    }

    // Start timeout on main or media widgets, and
    // pause it otherwise.
    if (widget.isHomeWidget()) {
        mTimeout.resume();
    } else {
        mTimeout.setTimeoutDelayed(mTimeoutNormal, true);
        mTimeout.pause();
    }
}

From source file:io.authme.sdk.widget.LockPatternView.java

/**
 * Determines whether the point x, y will add a new point to the current pattern (in addition to finding the cell,
 * also makes heuristic choices such as filling in gaps based on current pattern).
 *
 * @param x The x coordinate.//from  ww w  .  j  a  v a2 s  .  co m
 * @param y The y coordinate.
 */
@TargetApi(Build.VERSION_CODES.ECLAIR)
private Cell detectAndAddHit(float x, float y) {
    final Cell cell = checkForNewHit(x, y);
    if (cell != null) {

        // check for gaps in existing pattern
        Cell fillInGapCell = null;
        final ArrayList<Cell> pattern = mPattern;
        if (!pattern.isEmpty()) {
            final Cell lastCell = pattern.get(pattern.size() - 1);
            int dRow = cell.row - lastCell.row;
            int dColumn = cell.column - lastCell.column;

            int fillInRow = lastCell.row;
            int fillInColumn = lastCell.column;

            if (Math.abs(dRow) == 2 && Math.abs(dColumn) != 1) {
                fillInRow = lastCell.row + ((dRow > 0) ? 1 : -1);
            }

            if (Math.abs(dColumn) == 2 && Math.abs(dRow) != 1) {
                fillInColumn = lastCell.column + ((dColumn > 0) ? 1 : -1);
            }

            fillInGapCell = Cell.of(fillInRow, fillInColumn);
        }

        if (fillInGapCell != null && !mPatternDrawLookup[fillInGapCell.row][fillInGapCell.column]) {
            addCellToPattern(fillInGapCell);
        }
        addCellToPattern(cell);
        if (mEnableHapticFeedback) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR)
                performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY,
                        HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING
                                | HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
        }
        return cell;
    }
    return null;
}

From source file:de.dmarcini.bt.homelight.HomeLightMainActivity.java

@Override
public void onPageSelected(int position) {
    if (BuildConfig.DEBUG) {
        Log.v(TAG, String.format(Locale.ENGLISH, "page %02d selected", position));
    }/*from  ww  w.  j a  v a  2s. com*/
    mViewPager.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
    //
    // Gib dem Fragment order, dass es selektiert wurde
    // Hier ist die kritische Stelle
    IFragmentInterface handler = (IFragmentInterface) pagerAdapter
            .getRegisteredFragment(mViewPager.getCurrentItem());
    if (handler == null) {
        handler = (IFragmentInterface) pagerAdapter.getItem(mViewPager.getCurrentItem());
    }
    handler.onPageSelected();
}

From source file:org.mozilla.gecko.GeckoAppShell.java

public static void performHapticFeedback(boolean aIsLongPress) {
    // Don't perform haptic feedback if a vibration is currently playing,
    // because the haptic feedback will nuke the vibration.
    if (!sVibrationMaybePlaying || System.nanoTime() >= sVibrationEndTime) {
        LayerController layerController = GeckoApp.mAppContext.getLayerController();
        LayerView layerView = layerController.getView();
        layerView.performHapticFeedback(
                aIsLongPress ? HapticFeedbackConstants.LONG_PRESS : HapticFeedbackConstants.VIRTUAL_KEY);
    }//from  ww w  .j a v a2  s  . com
}

From source file:com.android.leanlauncher.LauncherTransitionable.java

public View.OnTouchListener getHapticFeedbackTouchListener() {
    if (mHapticFeedbackTouchListener == null) {
        mHapticFeedbackTouchListener = new View.OnTouchListener() {
            @Override// www  .  j  a v  a 2 s .  c o m
            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.android.launcher2.Launcher.java

/**
 * Event handler for the search button//w w w.j a va2s  .  com
 *
 * @param v The view that was clicked.
 */
public void onClickSearchButton(View v) {
    v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);

    onSearchRequested();
}

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

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

    try {
        final SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
        ComponentName activityName = searchManager.getGlobalSearchActivity();
        Intent intent = new Intent(RecognizerIntent.ACTION_WEB_SEARCH);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        if (activityName != null) {
            intent.setPackage(activityName.getPackageName());
        }
        startActivity(null, intent, "onClickVoiceButton");
    } catch (ActivityNotFoundException e) {
        Intent intent = new Intent(RecognizerIntent.ACTION_WEB_SEARCH);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivitySafely(null, intent, "onClickVoiceButton");
    }
}

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

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

From source file:com.gxapplications.android.gxsuite.launcher.Launcher.java

public void onClickDrawerSearchButton(View v) {
    v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);

    if (this.drawerLayout != null) {
        ((LauncherDrawerLayout) this.drawerLayout).openFromButton(this.mWorkspace);
    }/*from  w ww.ja va 2 s  .c o m*/
}