Unverified Commit e1ab8187 authored by Bart Mathijssen's avatar Bart Mathijssen Committed by GitHub

Use onBackPressed instead of onKeyDown (#1943)

parent 3e94ebc7
......@@ -560,22 +560,14 @@ public class Form extends AppInventorCompatActivity
/*
* Here we override the hardware back button, just to make sure
* that the closing screen animation is applied. (In API level
* 5, we can simply override the onBackPressed method rather
* than bothering with onKeyDown)
* that the closing screen animation is applied.
*/
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
if (!BackPressed()) {
boolean handled = super.onKeyDown(keyCode, event);
AnimationUtil.ApplyCloseScreenAnimation(this, closeAnimType);
return handled;
} else {
return true;
}
public void onBackPressed() {
if (!BackPressed()) {
AnimationUtil.ApplyCloseScreenAnimation(this, closeAnimType);
}
return super.onKeyDown(keyCode, event);
super.onBackPressed();
}
@SimpleEvent(description = "Device back button pressed.")
......
......@@ -157,15 +157,11 @@ public class ListPickerActivity extends AppInventorCompatActivity implements Ada
}
// Capture the hardware back button to make sure the screen animation
// still applies. (In API level 5, we can override onBackPressed instead)
// still applies.
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
boolean handled = super.onKeyDown(keyCode, event);
AnimationUtil.ApplyCloseScreenAnimation(this, closeAnim);
return handled;
}
return super.onKeyDown(keyCode, event);
public void onBackPressed() {
AnimationUtil.ApplyCloseScreenAnimation(this, closeAnim);
super.onBackPressed();
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment