Back button quitting

This commit is contained in:
Anuken
2019-03-31 13:16:43 -04:00
parent 801eadd8a8
commit c278c632b3
3 changed files with 14 additions and 0 deletions
@@ -52,6 +52,13 @@ public class AndroidLauncher extends AndroidApplication{
config.depth = 0; config.depth = 0;
Platform.instance = new Platform(){ Platform.instance = new Platform(){
@Override
public void hide(){
ui.showConfirm("$confirm", "$quit.confirm", () -> {
AndroidLauncher.this.moveTaskToBack(true);
});
}
@Override @Override
public void openDonations(){ public void openDonations(){
showDonations(); showDonations();
@@ -310,6 +310,10 @@ public class Control implements ApplicationListener{
if(!state.isPaused()){ if(!state.isPaused()){
Time.update(); Time.update();
} }
if(!scene.hasDialog() && Core.input.keyTap(KeyCode.BACK)){
Platform.instance.hide();
}
} }
} }
} }
@@ -69,6 +69,9 @@ public abstract class Platform {
*/ */
public void showFileChooser(String text, String content, Consumer<FileHandle> cons, boolean open, String filetype){} public void showFileChooser(String text, String content, Consumer<FileHandle> cons, boolean open, String filetype){}
/**Hide the app. Android only.*/
public void hide(){}
/**Forces the app into landscape mode. Currently Android only.*/ /**Forces the app into landscape mode. Currently Android only.*/
public void beginForceLandscape(){} public void beginForceLandscape(){}