List of usage examples for android.view KeyEvent KEYCODE_ESCAPE
int KEYCODE_ESCAPE
To view the source code for android.view KeyEvent KEYCODE_ESCAPE.
Click Source Link
From source file:com.appunite.appunitevideoplayer.PlayerActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().requestFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.player_activity); root = (ViewGroup) findViewById(R.id.root); root.setOnTouchListener(new OnTouchListener() { @Override/*from ww w. j a v a2 s. c om*/ public boolean onTouch(View view, MotionEvent motionEvent) { if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { toggleControlsVisibility(); } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) { view.performClick(); } return true; } }); root.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_ESCAPE || keyCode == KeyEvent.KEYCODE_MENU) { return false; } return mediaController.dispatchKeyEvent(event); } }); shutterView = findViewById(R.id.shutter); videoFrame = (AspectRatioFrameLayout) findViewById(R.id.video_frame); surfaceView = (SurfaceView) findViewById(R.id.surface_view); surfaceView.getHolder().addCallback(this); subtitleLayout = (SubtitleLayout) findViewById(R.id.subtitles); toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar.setNavigationIcon(R.drawable.ic_arrow_back); toolbar.setTitle(getIntent().getStringExtra(TITLE_TEXT_EXTRA)); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); } }); mediaController = new MediaController(this); mediaController.setAnchorView(root); controllerView = (ViewGroup) findViewById(R.id.controller_view); controllerView.addView(mediaController); CookieHandler currentHandler = CookieHandler.getDefault(); if (currentHandler != defaultCookieManager) { CookieHandler.setDefault(defaultCookieManager); } audioCapabilitiesReceiver = new AudioCapabilitiesReceiver(this, this); audioCapabilitiesReceiver.register(); progressBar = (ProgressBar) findViewById(R.id.progress_bar); playButton = (ImageView) findViewById(R.id.play_button_icon); final int playButtonIconDrawableId = getIntent().getIntExtra(PLAY_BUTTON_EXTRA, 0); if (playButtonIconDrawableId != 0) { playButton.setImageDrawable(ContextCompat.getDrawable(this, playButtonIconDrawableId)); playButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { preparePlayer(true); } }); } }
From source file:com.studyjams.mdvideo.PlayerModule.PlayerActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.player_activity); View root = findViewById(R.id.root); root.setOnTouchListener(new OnTouchListener() { @Override// w ww .jav a 2s . co m public boolean onTouch(View view, MotionEvent motionEvent) { if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { toggleControlsVisibility(); } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) { view.performClick(); } return true; } }); root.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_ESCAPE || keyCode == KeyEvent.KEYCODE_MENU) { return false; } return mediaController.dispatchKeyEvent(event); } }); shutterView = findViewById(R.id.shutter); // debugRootView = findViewById(R.id.controls_root); videoFrame = (AspectRatioFrameLayout) findViewById(R.id.video_frame); surfaceView = (SurfaceView) findViewById(R.id.surface_view); surfaceView.getHolder().addCallback(this); // debugTextView = (TextView) findViewById(R.id.debug_text_view); // playerStateTextView = (TextView) findViewById(R.id.player_state_view); subtitleLayout = (SubtitleLayout) findViewById(R.id.subtitles); mediaController = new ExtractorMediaController(this); mediaController.setAnchorView(root); // retryButton = (Button) findViewById(R.id.retry_button); // retryButton.setOnClickListener(this); // videoButton = (Button) findViewById(R.id.video_controls); // audioButton = (Button) findViewById(R.id.audio_controls); // textButton = (Button) findViewById(R.id.text_controls); //?mediaController??window setVolumeControlStream(AudioManager.STREAM_MUSIC); CookieHandler currentHandler = CookieHandler.getDefault(); if (currentHandler != defaultCookieManager) { CookieHandler.setDefault(defaultCookieManager); } audioCapabilitiesReceiver = new AudioCapabilitiesReceiver(this, this); audioCapabilitiesReceiver.register(); }
From source file:org.horaapps.leafpic.activities.PlayerActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(org.horaapps.leafpic.R.layout.activity_player); FrameLayout root = (FrameLayout) findViewById(org.horaapps.leafpic.R.id.root); findViewById(R.id.video_frame).setOnClickListener(new View.OnClickListener() { @Override/*from w w w. ja v a2 s.c o m*/ public void onClick(View view) { toggleControlsVisibility(); } }); root.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { return !(keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_ESCAPE || keyCode == KeyEvent.KEYCODE_MENU) && mediaController.dispatchKeyEvent(event); } }); root.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.md_black_1000)); shutterView = findViewById(org.horaapps.leafpic.R.id.shutter); videoFrame = (AspectRatioFrameLayout) findViewById(org.horaapps.leafpic.R.id.video_frame); surfaceView = (SurfaceView) findViewById(org.horaapps.leafpic.R.id.surface_view); surfaceView.getHolder().addCallback(this); mediaController = new CustomMediaController(this, this); mediController_anchor = findViewById(org.horaapps.leafpic.R.id.media_player_anchor); mediaController.setAnchorView(root); //mediaController.setPaddingRelative(0,0,0,Measure.getNavBarHeight(PlayerActivity.this)); toolbar = (Toolbar) findViewById(org.horaapps.leafpic.R.id.toolbar); initUI(); CookieHandler currentHandler = CookieHandler.getDefault(); if (currentHandler != defaultCookieManager) CookieHandler.setDefault(defaultCookieManager); audioCapabilitiesReceiver = new AudioCapabilitiesReceiver(this, this); audioCapabilitiesReceiver.register(); }
From source file:org.fossasia.phimpme.leafpic.activities.PlayerActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_player); FrameLayout root = (FrameLayout) findViewById(R.id.root); findViewById(R.id.video_frame).setOnClickListener(new View.OnClickListener() { @Override/*from w ww . j ava2 s .c o m*/ public void onClick(View view) { toggleControlsVisibility(); } }); root.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { return !(keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_ESCAPE || keyCode == KeyEvent.KEYCODE_MENU) && mediaController.dispatchKeyEvent(event); } }); root.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.md_black_1000)); shutterView = findViewById(R.id.shutter); videoFrame = (AspectRatioFrameLayout) findViewById(R.id.video_frame); surfaceView = (SurfaceView) findViewById(R.id.surface_view); surfaceView.getHolder().addCallback(this); mediaController = new CustomMediaController(this, this); mediController_anchor = findViewById(R.id.media_player_anchor); mediaController.setAnchorView(root); //mediaController.setPaddingRelative(0,0,0,Measure.getNavBarHeight(PlayerActivity.this)); toolbar = (Toolbar) findViewById(R.id.toolbar); initUI(); CookieHandler currentHandler = CookieHandler.getDefault(); if (currentHandler != defaultCookieManager) CookieHandler.setDefault(defaultCookieManager); audioCapabilitiesReceiver = new AudioCapabilitiesReceiver(this, this); audioCapabilitiesReceiver.register(); }
From source file:com.horaapps.leafpic.PlayerActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_player); FrameLayout root = (FrameLayout) findViewById(R.id.root); root.setOnTouchListener(new OnTouchListener() { @Override/* w ww . j a v a 2 s . co m*/ public boolean onTouch(View view, MotionEvent motionEvent) { if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { toggleControlsVisibility(); } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) { //view.performClick(); } return true; } }); root.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { return !(keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_ESCAPE || keyCode == KeyEvent.KEYCODE_MENU) && mediaController.dispatchKeyEvent(event); } }); root.setBackgroundColor(R.color.md_black_1000); shutterView = findViewById(R.id.shutter); videoFrame = (AspectRatioFrameLayout) findViewById(R.id.video_frame); surfaceView = (SurfaceView) findViewById(R.id.surface_view); surfaceView.getHolder().addCallback(this); mediaController = new KeyCompatibleMediaController(this); mediController_anchor = findViewById(R.id.media_player_anchor); mediaController.setAnchorView(mediController_anchor); mediaController.setPaddingRelative(0, 0, 0, Measure.getNavBarHeight(PlayerActivity.this)); toolbar = (Toolbar) findViewById(R.id.toolbar); initUI(); CookieHandler currentHandler = CookieHandler.getDefault(); if (currentHandler != defaultCookieManager) CookieHandler.setDefault(defaultCookieManager); audioCapabilitiesReceiver = new AudioCapabilitiesReceiver(this, this); audioCapabilitiesReceiver.register(); }
From source file:android.support.v17.leanback.app.PlaybackSupportFragment.java
private boolean onInterceptInputEvent(InputEvent event) { final boolean controlsHidden = !mControlVisible; if (DEBUG)//from w ww . j a v a 2 s. c o m Log.v(TAG, "onInterceptInputEvent hidden " + controlsHidden + " " + event); boolean consumeEvent = false; int keyCode = KeyEvent.KEYCODE_UNKNOWN; int keyAction = 0; if (event instanceof KeyEvent) { keyCode = ((KeyEvent) event).getKeyCode(); keyAction = ((KeyEvent) event).getAction(); if (mInputEventHandler != null) { consumeEvent = mInputEventHandler.onKey(getView(), keyCode, (KeyEvent) event); } } switch (keyCode) { case KeyEvent.KEYCODE_DPAD_CENTER: case KeyEvent.KEYCODE_DPAD_DOWN: case KeyEvent.KEYCODE_DPAD_UP: case KeyEvent.KEYCODE_DPAD_LEFT: case KeyEvent.KEYCODE_DPAD_RIGHT: // Event may be consumed; regardless, if controls are hidden then these keys will // bring up the controls. if (controlsHidden) { consumeEvent = true; } if (keyAction == KeyEvent.ACTION_DOWN) { tickle(); } break; case KeyEvent.KEYCODE_BACK: case KeyEvent.KEYCODE_ESCAPE: if (mInSeek) { // when in seek, the SeekUi will handle the BACK. return false; } // If controls are not hidden, back will be consumed to fade // them out (even if the key was consumed by the handler). if (!controlsHidden) { consumeEvent = true; if (((KeyEvent) event).getAction() == KeyEvent.ACTION_UP) { hideControlsOverlay(true); } } break; default: if (consumeEvent) { if (keyAction == KeyEvent.ACTION_DOWN) { tickle(); } } } return consumeEvent; }
From source file:com.redinput.datetimepickercompat.time.TimePickerDialog.java
/** * For keyboard mode, processes key events. * // w w w .jav a 2 s . co m * @param keyCode * the pressed key. * @return true if the key was successfully processed, false otherwise. */ private boolean processKeyUp(int keyCode) { if (keyCode == KeyEvent.KEYCODE_ESCAPE || keyCode == KeyEvent.KEYCODE_BACK) { dismiss(); return true; } else if (keyCode == KeyEvent.KEYCODE_TAB) { if (mInKbMode) { if (isTypedTimeFullyLegal()) { finishKbMode(true); } return true; } } else if (keyCode == KeyEvent.KEYCODE_ENTER) { if (mInKbMode) { if (!isTypedTimeFullyLegal()) { return true; } finishKbMode(false); } if (mCallback != null) { mCallback.onTimeSet(mTimePicker, mTimePicker.getHours(), mTimePicker.getMinutes()); } dismiss(); return true; } else if (keyCode == KeyEvent.KEYCODE_DEL) { if (mInKbMode) { if (!mTypedTimes.isEmpty()) { int deleted = deleteLastTypedKey(); String deletedKeyStr; if (deleted == getAmOrPmKeyCode(AM)) { deletedKeyStr = mAmText; } else if (deleted == getAmOrPmKeyCode(PM)) { deletedKeyStr = mPmText; } else { deletedKeyStr = String.format(Locale.getDefault(), "%d", getValFromKeyCode(deleted)); } Utils.tryAccessibilityAnnounce(mTimePicker, String.format(mDeletedKeyFormat, deletedKeyStr)); updateDisplay(true); } } } else if (keyCode == KeyEvent.KEYCODE_0 || keyCode == KeyEvent.KEYCODE_1 || keyCode == KeyEvent.KEYCODE_2 || keyCode == KeyEvent.KEYCODE_3 || keyCode == KeyEvent.KEYCODE_4 || keyCode == KeyEvent.KEYCODE_5 || keyCode == KeyEvent.KEYCODE_6 || keyCode == KeyEvent.KEYCODE_7 || keyCode == KeyEvent.KEYCODE_8 || keyCode == KeyEvent.KEYCODE_9 || (!mIs24HourMode && (keyCode == getAmOrPmKeyCode(AM) || keyCode == getAmOrPmKeyCode(PM)))) { if (!mInKbMode) { if (mTimePicker == null) { // Something's wrong, because time picker should definitely not be null. Log.e(TAG, "Unable to initiate keyboard mode, TimePicker was null."); return true; } mTypedTimes.clear(); tryStartingKbMode(keyCode); return true; } // We're already in keyboard mode. if (addKeyIfLegal(keyCode)) { updateDisplay(false); } return true; } return false; }
From source file:mirko.android.datetimepicker.time.TimePickerDialogSupport.java
/** * For keyboard mode, processes key events. * @param keyCode the pressed key.//from w w w. j ava2s .c om * @return true if the key was successfully processed, false otherwise. */ private boolean processKeyUp(int keyCode) { if (keyCode == KeyEvent.KEYCODE_ESCAPE || keyCode == KeyEvent.KEYCODE_BACK) { dismiss(); return true; } else if (keyCode == KeyEvent.KEYCODE_TAB) { if (mInKbMode) { if (isTypedTimeFullyLegal()) { finishKbMode(true); } return true; } } else if (keyCode == KeyEvent.KEYCODE_ENTER) { if (mInKbMode) { if (!isTypedTimeFullyLegal()) { return true; } finishKbMode(false); } if (mCallback != null) { mCallback.onTimeSet(this, mTimePicker.getHours(), mTimePicker.getMinutes()); } dismiss(); return true; } else if (keyCode == KeyEvent.KEYCODE_DEL) { if (mInKbMode) { if (!mTypedTimes.isEmpty()) { int deleted = deleteLastTypedKey(); String deletedKeyStr; if (deleted == getAmOrPmKeyCode(AM)) { deletedKeyStr = mAmText; } else if (deleted == getAmOrPmKeyCode(PM)) { deletedKeyStr = mPmText; } else { deletedKeyStr = String.format("%d", getValFromKeyCode(deleted)); } Utils.tryAccessibilityAnnounce(mTimePicker, String.format(mDeletedKeyFormat, deletedKeyStr)); updateDisplay(true); } } } else if (keyCode == KeyEvent.KEYCODE_0 || keyCode == KeyEvent.KEYCODE_1 || keyCode == KeyEvent.KEYCODE_2 || keyCode == KeyEvent.KEYCODE_3 || keyCode == KeyEvent.KEYCODE_4 || keyCode == KeyEvent.KEYCODE_5 || keyCode == KeyEvent.KEYCODE_6 || keyCode == KeyEvent.KEYCODE_7 || keyCode == KeyEvent.KEYCODE_8 || keyCode == KeyEvent.KEYCODE_9 || (!mIs24HourMode && (keyCode == getAmOrPmKeyCode(AM) || keyCode == getAmOrPmKeyCode(PM)))) { if (!mInKbMode) { if (mTimePicker == null) { // Something's wrong, because time picker should definitely not be null. Log.e(TAG, "Unable to initiate keyboard mode, TimePicker was null."); return true; } mTypedTimes.clear(); tryStartingKbMode(keyCode); return true; } // We're already in keyboard mode. if (addKeyIfLegal(keyCode)) { updateDisplay(false); } return true; } return false; }
From source file:com.gcloud.gaadi.ui.sleepbot.datetimepicker.time.TimePickerDialog.java
/** * For keyboard mode, processes key events. * * @param keyCode the pressed key./*from ww w. j a v a 2 s . c o m*/ * @return true if the key was successfully processed, false otherwise. */ private boolean processKeyUp(int keyCode) { if (keyCode == KeyEvent.KEYCODE_ESCAPE || keyCode == KeyEvent.KEYCODE_BACK) { dismiss(); return true; } else if (keyCode == KeyEvent.KEYCODE_TAB) { if (mInKbMode) { if (isTypedTimeFullyLegal()) { finishKbMode(true); } return true; } } else if (keyCode == KeyEvent.KEYCODE_ENTER) { if (mInKbMode) { if (!isTypedTimeFullyLegal()) { return true; } finishKbMode(false); } if (mCallback != null) { mCallback.onTimeSet(mTimePicker, mTimePicker.getHours(), mTimePicker.getMinutes()); } dismiss(); return true; } else if (keyCode == KeyEvent.KEYCODE_DEL) { if (mInKbMode) { if (!mTypedTimes.isEmpty()) { int deleted = deleteLastTypedKey(); String deletedKeyStr; if (deleted == getAmOrPmKeyCode(AM)) { deletedKeyStr = mAmText; } else if (deleted == getAmOrPmKeyCode(PM)) { deletedKeyStr = mPmText; } else { deletedKeyStr = String.format("%d", getValFromKeyCode(deleted)); } Utils.tryAccessibilityAnnounce(mTimePicker, String.format(mDeletedKeyFormat, deletedKeyStr)); updateDisplay(true); } } } else if (keyCode == KeyEvent.KEYCODE_0 || keyCode == KeyEvent.KEYCODE_1 || keyCode == KeyEvent.KEYCODE_2 || keyCode == KeyEvent.KEYCODE_3 || keyCode == KeyEvent.KEYCODE_4 || keyCode == KeyEvent.KEYCODE_5 || keyCode == KeyEvent.KEYCODE_6 || keyCode == KeyEvent.KEYCODE_7 || keyCode == KeyEvent.KEYCODE_8 || keyCode == KeyEvent.KEYCODE_9 || (!mIs24HourMode && (keyCode == getAmOrPmKeyCode(AM) || keyCode == getAmOrPmKeyCode(PM)))) { if (!mInKbMode) { if (mTimePicker == null) { // Something's wrong, because time picker should definitely not be null. GCLog.e("Unable to initiate keyboard mode, TimePicker was null."); return true; } mTypedTimes.clear(); tryStartingKbMode(keyCode); return true; } // We're already in keyboard mode. if (addKeyIfLegal(keyCode)) { updateDisplay(false); } return true; } return false; }
From source file:cn.fulldroid.lib.datetimepicker.time.TimePickerDialog.java
/** * For keyboard mode, processes key events. * * @param keyCode the pressed key.//from w w w . ja v a 2 s . co m * @return true if the key was successfully processed, false otherwise. */ private boolean processKeyUp(int keyCode) { if (keyCode == KeyEvent.KEYCODE_ESCAPE || keyCode == KeyEvent.KEYCODE_BACK) { dismiss(); return true; } else if (keyCode == KeyEvent.KEYCODE_TAB) { if (mInKbMode) { if (isTypedTimeFullyLegal()) { finishKbMode(true); } return true; } } else if (keyCode == KeyEvent.KEYCODE_ENTER) { if (mInKbMode) { if (!isTypedTimeFullyLegal()) { return true; } finishKbMode(false); } if (mCallback != null) { mCallback.onTimeSet(mTimePicker, mTimePicker.getHours(), mTimePicker.getMinutes()); } dismiss(); return true; } else if (keyCode == KeyEvent.KEYCODE_DEL) { if (mInKbMode) { if (!mTypedTimes.isEmpty()) { int deleted = deleteLastTypedKey(); String deletedKeyStr; if (deleted == getAmOrPmKeyCode(AM)) { deletedKeyStr = mAmText; } else if (deleted == getAmOrPmKeyCode(PM)) { deletedKeyStr = mPmText; } else { deletedKeyStr = String.format("%d", getValFromKeyCode(deleted)); } Utils.tryAccessibilityAnnounce(mTimePicker, String.format(mDeletedKeyFormat, deletedKeyStr)); updateDisplay(true); } } } else if (keyCode == KeyEvent.KEYCODE_0 || keyCode == KeyEvent.KEYCODE_1 || keyCode == KeyEvent.KEYCODE_2 || keyCode == KeyEvent.KEYCODE_3 || keyCode == KeyEvent.KEYCODE_4 || keyCode == KeyEvent.KEYCODE_5 || keyCode == KeyEvent.KEYCODE_6 || keyCode == KeyEvent.KEYCODE_7 || keyCode == KeyEvent.KEYCODE_8 || keyCode == KeyEvent.KEYCODE_9 || (!mIs24HourMode && (keyCode == getAmOrPmKeyCode(AM) || keyCode == getAmOrPmKeyCode(PM)))) { if (!mInKbMode) { if (mTimePicker == null) { // Something's wrong, because time picker should definitely not be null. Log.e(TAG, "Unable to initiate keyboard mode, TimePicker was null."); return true; } mTypedTimes.clear(); tryStartingKbMode(keyCode); return true; } // We're already in keyboard mode. if (addKeyIfLegal(keyCode)) { updateDisplay(false); } return true; } return false; }