mirror of
https://github.com/moparisthebest/k-9
synced 2025-01-12 06:08:25 -05:00
Fixed problem with back button because of custom dispatchKeyEvent()
This commit is contained in:
parent
d82d0a220c
commit
73edf5c31a
@ -117,7 +117,7 @@ public class MessageView extends K9Activity implements OnClickListener {
|
|||||||
public boolean dispatchKeyEvent(KeyEvent event) {
|
public boolean dispatchKeyEvent(KeyEvent event) {
|
||||||
boolean ret = false;
|
boolean ret = false;
|
||||||
if (KeyEvent.ACTION_DOWN == event.getAction()) {
|
if (KeyEvent.ACTION_DOWN == event.getAction()) {
|
||||||
ret = onKeyDown(event.getKeyCode(), event);
|
ret = onCustomKeyDown(event.getKeyCode(), event);
|
||||||
}
|
}
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
ret = super.dispatchKeyEvent(event);
|
ret = super.dispatchKeyEvent(event);
|
||||||
@ -125,29 +125,36 @@ public class MessageView extends K9Activity implements OnClickListener {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
public boolean onKeyDown(final int keyCode, final KeyEvent event) {
|
* Handle hotkeys
|
||||||
if (
|
*
|
||||||
// XXX TODO - when we go to android 2.0, uncomment this
|
* <p>
|
||||||
// android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.ECLAIR &&
|
* This method is called by {@link #dispatchKeyEvent(KeyEvent)} before any view had the chance
|
||||||
keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
|
* to consume this key event.
|
||||||
// Take care of calling this method on earlier versions of
|
* </p>
|
||||||
// the platform where it doesn't exist.
|
*
|
||||||
onBackPressed();
|
* @param keyCode
|
||||||
return true;
|
* The value in {@code event.getKeyCode()}.
|
||||||
}
|
* @param event
|
||||||
|
* Description of the key event.
|
||||||
|
*
|
||||||
|
* @return {@code true} if this event was consumed.
|
||||||
|
*/
|
||||||
|
public boolean onCustomKeyDown(final int keyCode, final KeyEvent event) {
|
||||||
switch (keyCode) {
|
switch (keyCode) {
|
||||||
case KeyEvent.KEYCODE_VOLUME_UP: {
|
case KeyEvent.KEYCODE_VOLUME_UP: {
|
||||||
if (K9.useVolumeKeysForNavigationEnabled()) {
|
if (K9.useVolumeKeysForNavigationEnabled()) {
|
||||||
onNext();
|
onNext();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case KeyEvent.KEYCODE_VOLUME_DOWN: {
|
case KeyEvent.KEYCODE_VOLUME_DOWN: {
|
||||||
if (K9.useVolumeKeysForNavigationEnabled()) {
|
if (K9.useVolumeKeysForNavigationEnabled()) {
|
||||||
onPrevious();
|
onPrevious();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case KeyEvent.KEYCODE_SHIFT_LEFT:
|
case KeyEvent.KEYCODE_SHIFT_LEFT:
|
||||||
case KeyEvent.KEYCODE_SHIFT_RIGHT: {
|
case KeyEvent.KEYCODE_SHIFT_RIGHT: {
|
||||||
@ -222,7 +229,7 @@ public class MessageView extends K9Activity implements OnClickListener {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return super.onKeyDown(keyCode, event);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user