Skip to content

Commit

Permalink
增加esc键视同返回
Browse files Browse the repository at this point in the history
  • Loading branch information
Eanya-Tonic committed Oct 2, 2024
1 parent 7309152 commit 24825b6
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions app/src/main/java/com/eanyatonic/cctvViewer/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public class MainActivity extends AppCompatActivity {

private int TEXT_SIZE = 22;
private Boolean enableDualWebView = true;
private Boolean enableDirectChange = false;


@Override
Expand Down Expand Up @@ -664,7 +665,7 @@ public boolean dispatchKeyEvent(KeyEvent event) {
audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_LOWER, AudioManager.FLAG_SHOW_UI);
} else if (menuOverlay.hasFocus()) {
// menuOverlay具有焦点
if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
if (event.getKeyCode() == KeyEvent.KEYCODE_BACK || event.getKeyCode() == KeyEvent.KEYCODE_ESCAPE) {
// 按下返回键
showMenuOverlay();
return true;
Expand Down Expand Up @@ -793,7 +794,7 @@ function zoomOut() {
}
if (DrawerLayout.hasFocus() && !SubMenuCCTV.hasFocus() && !SubMenuLocal.hasFocus() && !DrawerLayoutDetailed.hasFocus()) {
// DrawerLayout具有焦点
if (event.getKeyCode() == KeyEvent.KEYCODE_BACK || event.getKeyCode() == KeyEvent.KEYCODE_DPAD_LEFT) {
if (event.getKeyCode() == KeyEvent.KEYCODE_BACK || event.getKeyCode() == KeyEvent.KEYCODE_DPAD_LEFT || event.getKeyCode() == KeyEvent.KEYCODE_ESCAPE) {
// 按下返回键
showChannelList();
return true;
Expand Down Expand Up @@ -839,7 +840,7 @@ function zoomOut() {
return true;
}
} else if (SubMenuCCTV.hasFocus()) {
if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
if (event.getKeyCode() == KeyEvent.KEYCODE_BACK || event.getKeyCode() == KeyEvent.KEYCODE_ESCAPE) {
// 按下返回键
DrawerLayout.getChildAt(DrawerLayoutSelectedIndex).requestFocus();
SubMenuCCTV.setVisibility(View.GONE);
Expand Down Expand Up @@ -878,7 +879,7 @@ function zoomOut() {
return true;
}
} else if (SubMenuLocal.hasFocus()) {
if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
if (event.getKeyCode() == KeyEvent.KEYCODE_BACK || event.getKeyCode() == KeyEvent.KEYCODE_ESCAPE) {
// 按下返回键
DrawerLayout.getChildAt(DrawerLayoutSelectedIndex).requestFocus();
SubMenuLocal.setVisibility(View.GONE);
Expand Down Expand Up @@ -950,7 +951,7 @@ function zoomOut() {
updateInputTextView();

return true; // 事件已处理,不传递给 WebView
} else if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
} else if (event.getKeyCode() == KeyEvent.KEYCODE_BACK || event.getKeyCode() == KeyEvent.KEYCODE_ESCAPE) {
if (doubleBackToExitPressedOnce) {
super.onBackPressed();
System.exit(0);
Expand Down

0 comments on commit 24825b6

Please sign in to comment.