Java Code Examples for android.view.KeyEvent#startTracking()

The following examples show how to use android.view.KeyEvent#startTracking() . 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: HListView.java    From TV-HorizontalListView with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    boolean handled = false;
    switch (keyCode) {
        case KeyEvent.KEYCODE_DPAD_LEFT:
            handled = moveLeft();
            break;
        case KeyEvent.KEYCODE_DPAD_RIGHT:
            handled = moveRight();
            break;
        case KeyEvent.KEYCODE_DPAD_CENTER:
        case KeyEvent.KEYCODE_NUMPAD_ENTER:
        case KeyEvent.KEYCODE_ENTER:
            event.startTracking();
            handled = true;
            break;
    }
    return handled || super.onKeyDown(keyCode, event);
}
 
Example 2
Source File: AppMenu.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
    if (mPopup == null || mPopup.getListView() == null) return false;

    if (event.getKeyCode() == KeyEvent.KEYCODE_MENU) {
        if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) {
            event.startTracking();
            v.getKeyDispatcherState().startTracking(event, this);
            return true;
        } else if (event.getAction() == KeyEvent.ACTION_UP) {
            v.getKeyDispatcherState().handleUpEvent(event);
            if (event.isTracking() && !event.isCanceled()) {
                dismiss();
                return true;
            }
        }
    }
    return false;
}
 
Example 3
Source File: AppMenu.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
    if (mPopup == null || mPopup.getListView() == null) return false;

    if (event.getKeyCode() == KeyEvent.KEYCODE_MENU) {
        if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) {
            event.startTracking();
            v.getKeyDispatcherState().startTracking(event, this);
            return true;
        } else if (event.getAction() == KeyEvent.ACTION_UP) {
            v.getKeyDispatcherState().handleUpEvent(event);
            if (event.isTracking() && !event.isCanceled()) {
                dismiss();
                return true;
            }
        }
    }
    return false;
}
 
Example 4
Source File: ImageViewTouchBase.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
        event.startTracking();
        return true;
    }
    return super.onKeyDown(keyCode, event);
}
 
Example 5
Source File: ImageViewTouchBase.java    From reader with MIT License 5 votes vote down vote up
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK
            && event.getRepeatCount() == 0) {
        event.startTracking();
        return true;
    }
    return super.onKeyDown(keyCode, event);
}
 
Example 6
Source File: ImageViewTouchBase.java    From droidddle with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
        event.startTracking();
        return true;
    }
    return super.onKeyDown(keyCode, event);
}
 
Example 7
Source File: ArticleCollectionActivity.java    From aard2-android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_VOLUME_UP || keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
        if (!useVolumeForNav()) {
            return false;
        }
        event.startTracking();
        return true;
    }
    return super.onKeyDown(keyCode, event);
}
 
Example 8
Source File: ImageViewTouchBase.java    From yiim_v2 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
	if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
		event.startTracking();
		return true;
	}
	return super.onKeyDown(keyCode, event);
}
 
Example 9
Source File: ImageViewTouchBase.java    From HaiNaBaiChuan with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
        event.startTracking();
        return true;
    }
    return super.onKeyDown(keyCode, event);
}
 
Example 10
Source File: MasterFragmentDelegate.java    From FragmentMaster with Apache License 2.0 5 votes vote down vote up
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        if (mFragmentContext.getApplicationInfo().targetSdkVersion
                >= Build.VERSION_CODES.ECLAIR) {
            event.startTracking();
        } else {
            onBackPressed();
        }
        return true;
    }
    return false;
}
 
Example 11
Source File: ImageViewTouchBase.java    From GalleryFinal with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
        event.startTracking();
        return true;
    }
    return super.onKeyDown(keyCode, event);
}
 
Example 12
Source File: MainActivity.java    From letv with Apache License 2.0 5 votes vote down vote up
public boolean onKeyDown(int keyCode, KeyEvent event) {
    switch (keyCode) {
        case 4:
            event.startTracking();
            return true;
        case 24:
        case 25:
            this.mLiveFragment.onKeyDown(keyCode, event);
            break;
    }
    return super.onKeyDown(keyCode, event);
}
 
Example 13
Source File: ImageViewTouchBase.java    From XERUNG with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
        event.startTracking();
        return true;
    }
    return super.onKeyDown(keyCode, event);
}
 
Example 14
Source File: ImageViewTouchBase.java    From XERUNG with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
        event.startTracking();
        return true;
    }
    return super.onKeyDown(keyCode, event);
}
 
Example 15
Source File: LauncherAppWidgetHostView.java    From LaunchEnr with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (!mChildrenFocused && keyCode == KeyEvent.KEYCODE_ENTER) {
        event.startTracking();
        return true;
    }
    return super.onKeyDown(keyCode, event);
}
 
Example 16
Source File: TapTargetView.java    From styT with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (isVisible() && cancelable && keyCode == KeyEvent.KEYCODE_BACK) {
        event.startTracking();
        return true;
    }

    return false;
}
 
Example 17
Source File: VolumePanel.java    From Noyze with Apache License 2.0 4 votes vote down vote up
@Override
public boolean onKey(View v, final int keyCode, KeyEvent event) {
       LOGI("VolumePanel", "onKey(" + keyCode + ")");

       // Don't handle ANYTHING when a call is in progress!
       if (mCallState != TelephonyManager.CALL_STATE_IDLE)
           return super.onKey(v, keyCode, event);

	switch (keyCode) {
		// Handle the DOWN + MULTIPLE action (holding down).
           case KeyEvent.KEYCODE_VOLUME_UP:
           case KeyEvent.KEYCODE_VOLUME_DOWN:
           	final int adjust = ((keyCode == KeyEvent.KEYCODE_VOLUME_UP) ?
                           	 AudioManager.ADJUST_RAISE : AudioManager.ADJUST_LOWER);
           	switch (event.getAction()) {
                   case KeyEvent.ACTION_DOWN:
                       // If another key was pressed while holding on to
                       // one volume key, we'll need to abort mission.
                       if (mKeyCodeDown != 0) {
                           mIgnoreNextKeyUp = true;
                           mHandler.removeMessages(MSG_VOLUME_LONG_PRESS);
                           return super.onKey(v, keyCode, event);
                       }

                       mKeyCodeDown = event.getKeyCode();
                       mKeyTimeDown = System.currentTimeMillis();
                       event.startTracking();

                       // NOTE: we'll allow long press events if we've set an action.
                       boolean callIdle = (mCallState == TelephonyManager.CALL_STATE_IDLE);
                       if (!noLongPress || hasLongPressAction(keyCode)) {
                           mHandler.sendMessageDelayed(mHandler.obtainMessage(
                                   MSG_VOLUME_LONG_PRESS, event), ((callIdle && hasLongPressAction(keyCode)) ?
                                   mLongPressTimeout : mLongPressTimeout / 2));
                       }
                       break;
           		case KeyEvent.ACTION_UP:
           		case KeyEvent.ACTION_MULTIPLE:
                       boolean hasLongPress = mHandler.hasMessages(MSG_VOLUME_LONG_PRESS);
                       mHandler.removeMessages(MSG_VOLUME_LONG_PRESS);
                       boolean ignoreNextKeyUp = mIgnoreNextKeyUp;
                       mIgnoreNextKeyUp = false;
                       mKeyCodeDown = 0;

                       // We've been told to let this one go.
                       if (ignoreNextKeyUp || event.isCanceled()) {
                           mKeyTimeDown = 0;
                           return true;
                       }

                       if ((hasLongPress || noLongPress) && (System.currentTimeMillis() -
                               mKeyTimeDown) < mLongPressTimeout) {
                           mVolumeDirty = true;
                           mKeyTimeDown = 0;
                           if (!firstReveal || (firstReveal && isShowing())) {
                               adjustVolume(adjust);
                               show();
                           } else {
                               reveal();
                           }
                       }
           			break;
           	}
               break;
           case KeyEvent.KEYCODE_VOLUME_MUTE:
               switch (event.getAction()) {
                   case KeyEvent.ACTION_UP:
                       boolean mute = isMuted(STREAM_RING);
                       mAudioManager.setStreamMute(STREAM_RING, !mute);
                       mAudioManager.setStreamMute(STREAM_NOTIFICATION, !mute);
                       mVolumeDirty = true;
                       show();
                       break;
               }
               break;
       }

       return super.onKey(v, keyCode, event);
}
 
Example 18
Source File: KeyEventCompatEclair.java    From adt-leanback-support with Apache License 2.0 4 votes vote down vote up
public static void startTracking(KeyEvent event) {
    event.startTracking();
}
 
Example 19
Source File: VolumePanel.java    From Noyze with Apache License 2.0 4 votes vote down vote up
@Override
public boolean onKey(View v, final int keyCode, KeyEvent event) {
       LOGI("VolumePanel", "onKey(" + keyCode + ")");

       // Don't handle ANYTHING when a call is in progress!
       if (mCallState != TelephonyManager.CALL_STATE_IDLE)
           return super.onKey(v, keyCode, event);

	switch (keyCode) {
		// Handle the DOWN + MULTIPLE action (holding down).
           case KeyEvent.KEYCODE_VOLUME_UP:
           case KeyEvent.KEYCODE_VOLUME_DOWN:
           	final int adjust = ((keyCode == KeyEvent.KEYCODE_VOLUME_UP) ?
                           	 AudioManager.ADJUST_RAISE : AudioManager.ADJUST_LOWER);
           	switch (event.getAction()) {
                   case KeyEvent.ACTION_DOWN:
                       // If another key was pressed while holding on to
                       // one volume key, we'll need to abort mission.
                       if (mKeyCodeDown != 0) {
                           mIgnoreNextKeyUp = true;
                           mHandler.removeMessages(MSG_VOLUME_LONG_PRESS);
                           return super.onKey(v, keyCode, event);
                       }

                       mKeyCodeDown = event.getKeyCode();
                       mKeyTimeDown = System.currentTimeMillis();
                       event.startTracking();

                       // NOTE: we'll allow long press events if we've set an action.
                       boolean callIdle = (mCallState == TelephonyManager.CALL_STATE_IDLE);
                       if (!noLongPress || hasLongPressAction(keyCode)) {
                           mHandler.sendMessageDelayed(mHandler.obtainMessage(
                                   MSG_VOLUME_LONG_PRESS, event), ((callIdle && hasLongPressAction(keyCode)) ?
                                   mLongPressTimeout : mLongPressTimeout / 2));
                       }
                       break;
           		case KeyEvent.ACTION_UP:
           		case KeyEvent.ACTION_MULTIPLE:
                       boolean hasLongPress = mHandler.hasMessages(MSG_VOLUME_LONG_PRESS);
                       mHandler.removeMessages(MSG_VOLUME_LONG_PRESS);
                       boolean ignoreNextKeyUp = mIgnoreNextKeyUp;
                       mIgnoreNextKeyUp = false;
                       mKeyCodeDown = 0;

                       // We've been told to let this one go.
                       if (ignoreNextKeyUp || event.isCanceled()) {
                           mKeyTimeDown = 0;
                           return true;
                       }

                       if ((hasLongPress || noLongPress) && (System.currentTimeMillis() -
                               mKeyTimeDown) < mLongPressTimeout) {
                           mVolumeDirty = true;
                           mKeyTimeDown = 0;
                           if (!firstReveal || (firstReveal && isShowing())) {
                               adjustVolume(adjust);
                               show();
                           } else {
                               reveal();
                           }
                       }
           			break;
           	}
               break;
           case KeyEvent.KEYCODE_VOLUME_MUTE:
               switch (event.getAction()) {
                   case KeyEvent.ACTION_UP:
                       boolean mute = isMuted(STREAM_RING);
                       mAudioManager.setStreamMute(STREAM_RING, !mute);
                       mAudioManager.setStreamMute(STREAM_NOTIFICATION, !mute);
                       mVolumeDirty = true;
                       show();
                       break;
               }
               break;
       }

       return super.onKey(v, keyCode, event);
}
 
Example 20
Source File: KeyEventCompatEclair.java    From CodenameOne with GNU General Public License v2.0 4 votes vote down vote up
public static void startTracking(KeyEvent event) {
    event.startTracking();
}