Mercurial > 510Connectbot
comparison src/com/five_ten_sg/connectbot/service/TerminalKeyListener.java @ 237:f9b1a07c0e96
configurable hardware buttons can now change font size
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Mon, 14 Jul 2014 08:46:06 -0700 |
parents | c6157535e180 |
children | 071eccdff8ea |
comparison
equal
deleted
inserted
replaced
236:35ed530366d9 | 237:f9b1a07c0e96 |
---|---|
566 | 566 |
567 return false; | 567 return false; |
568 } | 568 } |
569 | 569 |
570 private boolean handleShortcuts(View v, int keyCode, KeyEvent event, int repeat, boolean down) { | 570 private boolean handleShortcuts(View v, int keyCode, KeyEvent event, int repeat, boolean down) { |
571 String hwbuttonShortcut; | |
571 switch (keyCode) { | 572 switch (keyCode) { |
572 case KeyEvent.KEYCODE_CAMERA: | 573 case KeyEvent.KEYCODE_CAMERA: |
573 // check to see which shortcut the camera button triggers | 574 // check to see which shortcut the camera button triggers |
574 String hwbuttonShortcut = manager.prefs.getString( | 575 hwbuttonShortcut = manager.prefs.getString( |
575 PreferenceConstants.CAMERA, | 576 PreferenceConstants.CAMERA, |
576 PreferenceConstants.HWBUTTON_SCREEN_CAPTURE); | 577 PreferenceConstants.HWBUTTON_SCREEN_CAPTURE); |
577 return (handleShortcut(v, hwbuttonShortcut, repeat, down)); | 578 return (handleShortcut(v, hwbuttonShortcut, repeat, down)); |
578 | 579 |
579 case KeyEvent.KEYCODE_VOLUME_UP: | 580 case KeyEvent.KEYCODE_VOLUME_UP: |
580 // check to see which shortcut the volume button triggers | 581 // check to see which shortcut the volume button triggers |
581 hwbuttonShortcut = manager.prefs.getString( | 582 hwbuttonShortcut = manager.prefs.getString( |
582 PreferenceConstants.VOLUP, | 583 PreferenceConstants.VOLUP, |
583 PreferenceConstants.HWBUTTON_FUNCTION_KEYS); | 584 PreferenceConstants.HWBUTTON_FUNCTION_KEYS); |
584 return (handleShortcut(v, hwbuttonShortcut, repeat, down)); | 585 return (handleShortcut(v, hwbuttonShortcut, repeat, down)); |
585 | 586 |
586 case KeyEvent.KEYCODE_VOLUME_DOWN: | 587 case KeyEvent.KEYCODE_VOLUME_DOWN: |
587 // check to see which shortcut the camera button triggers | 588 // check to see which shortcut the camera button triggers |
588 hwbuttonShortcut = manager.prefs.getString( | 589 hwbuttonShortcut = manager.prefs.getString( |
589 PreferenceConstants.VOLDN, | 590 PreferenceConstants.VOLDN, |
590 PreferenceConstants.HWBUTTON_TAB); | 591 PreferenceConstants.HWBUTTON_TAB); |
591 return (handleShortcut(v, hwbuttonShortcut, repeat, down)); | 592 return (handleShortcut(v, hwbuttonShortcut, repeat, down)); |
592 | 593 |
593 case KeyEvent.KEYCODE_SEARCH: | 594 case KeyEvent.KEYCODE_SEARCH: |
594 // check to see which shortcut the search button triggers | 595 // check to see which shortcut the search button triggers |
595 hwbuttonShortcut = manager.prefs.getString( | 596 hwbuttonShortcut = manager.prefs.getString( |
596 PreferenceConstants.SEARCH, | 597 PreferenceConstants.SEARCH, |
597 PreferenceConstants.HWBUTTON_ESC); | 598 PreferenceConstants.HWBUTTON_ESC); |
598 return (handleShortcut(v, hwbuttonShortcut, repeat, down)); | 599 return (handleShortcut(v, hwbuttonShortcut, repeat, down)); |
599 | 600 |
600 case KeyEvent.KEYCODE_BUTTON_L2: | 601 case KeyEvent.KEYCODE_BUTTON_L2: |
601 // check to see which shortcut the ptt button triggers | 602 // check to see which shortcut the ptt button triggers |
602 hwbuttonShortcut = manager.prefs.getString( | 603 hwbuttonShortcut = manager.prefs.getString( |
603 PreferenceConstants.PTT, | 604 PreferenceConstants.PTT, |
604 PreferenceConstants.HWBUTTON_MONITOR); | 605 PreferenceConstants.HWBUTTON_MONITOR); |
605 return (handleShortcut(v, hwbuttonShortcut, repeat, down)); | 606 return (handleShortcut(v, hwbuttonShortcut, repeat, down)); |
606 | 607 |
607 default: return false; | 608 default: return false; |
608 } | 609 } |
609 } | 610 } |
610 | 611 |
611 private boolean handleShortcut(View v, String shortcut, int repeat, boolean down) { | 612 private boolean handleShortcut(View v, String shortcut, int repeat, boolean down) { |
612 if (PreferenceConstants.HWBUTTON_FUNCTION_KEYS.equals(shortcut)) { | 613 if (PreferenceConstants.HWBUTTON_DECREASE_FONTSIZE.equals(shortcut)) { |
614 if (!down) return false; | |
615 bridge.decreaseFontSize(); | |
616 } | |
617 else if (PreferenceConstants.HWBUTTON_INCREASE_FONTSIZE.equals(shortcut)) { | |
618 if (!down) return false; | |
619 bridge.increaseFontSize(); | |
620 } | |
621 else if (PreferenceConstants.HWBUTTON_FUNCTION_KEYS.equals(shortcut)) { | |
613 if (repeat > 0) return false; | 622 if (repeat > 0) return false; |
614 if (!down) return false; | 623 if (!down) return false; |
615 bridge.showFKeysDialog(); | 624 bridge.showFKeysDialog(); |
625 } | |
626 else if (PreferenceConstants.HWBUTTON_MONITOR.equals(shortcut)) { | |
627 if (repeat > 0) return false; | |
628 buffer.monitorKey(down); | |
616 } | 629 } |
617 else if (PreferenceConstants.HWBUTTON_SCREEN_CAPTURE.equals(shortcut)) { | 630 else if (PreferenceConstants.HWBUTTON_SCREEN_CAPTURE.equals(shortcut)) { |
618 if (repeat > 0) return false; | 631 if (repeat > 0) return false; |
619 if (!down) return false; | 632 if (!down) return false; |
620 bridge.captureScreen(); | 633 bridge.captureScreen(); |
621 } | |
622 else if (PreferenceConstants.HWBUTTON_MONITOR.equals(shortcut)) { | |
623 if (repeat > 0) return false; | |
624 buffer.monitorKey(down); | |
625 } | 634 } |
626 else if (PreferenceConstants.HWBUTTON_CTRL.equals(shortcut)) { | 635 else if (PreferenceConstants.HWBUTTON_CTRL.equals(shortcut)) { |
627 if (!down) return false; | 636 if (!down) return false; |
628 showMetakeyToast(v, PreferenceConstants.HWBUTTON_CTRL); | 637 showMetakeyToast(v, PreferenceConstants.HWBUTTON_CTRL); |
629 metaPress(META_CTRL_ON); | 638 metaPress(META_CTRL_ON); |