Deal with canceled keys.
This commit is contained in:
@@ -110,6 +110,9 @@ public class Home extends Activity {
|
|||||||
|
|
||||||
private boolean mBlockAnimation;
|
private boolean mBlockAnimation;
|
||||||
|
|
||||||
|
private boolean mHomeDown;
|
||||||
|
private boolean mBackDown;
|
||||||
|
|
||||||
private View mShowApplications;
|
private View mShowApplications;
|
||||||
private CheckBox mShowApplicationsCheck;
|
private CheckBox mShowApplicationsCheck;
|
||||||
|
|
||||||
@@ -395,13 +398,38 @@ public class Home extends Activity {
|
|||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onWindowFocusChanged(boolean hasFocus) {
|
||||||
|
super.onWindowFocusChanged(hasFocus);
|
||||||
|
if (!hasFocus) {
|
||||||
|
mBackDown = mHomeDown = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean dispatchKeyEvent(KeyEvent event) {
|
public boolean dispatchKeyEvent(KeyEvent event) {
|
||||||
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||||
switch (event.getKeyCode()) {
|
switch (event.getKeyCode()) {
|
||||||
case KeyEvent.KEYCODE_BACK:
|
case KeyEvent.KEYCODE_BACK:
|
||||||
|
mBackDown = true;
|
||||||
return true;
|
return true;
|
||||||
case KeyEvent.KEYCODE_HOME:
|
case KeyEvent.KEYCODE_HOME:
|
||||||
|
mHomeDown = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else if (event.getAction() == KeyEvent.ACTION_UP) {
|
||||||
|
switch (event.getKeyCode()) {
|
||||||
|
case KeyEvent.KEYCODE_BACK:
|
||||||
|
if (!event.isCanceled()) {
|
||||||
|
// Do BACK behavior.
|
||||||
|
}
|
||||||
|
mBackDown = true;
|
||||||
|
return true;
|
||||||
|
case KeyEvent.KEYCODE_HOME:
|
||||||
|
if (!event.isCanceled()) {
|
||||||
|
// Do HOME behavior.
|
||||||
|
}
|
||||||
|
mHomeDown = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user