- Don't crash on back press, but shutdown hedgewars
authorXeli
Sat, 21 Apr 2012 18:02:44 +0200
changeset 6901 c021699c33dc
parent 6900 26873e68034f
child 6902 7d4e5ce73b98
- Don't crash on back press, but shutdown hedgewars - enable volume up/down/mute buttons
project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/SDLActivity.java
--- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/SDLActivity.java	Sat Apr 21 17:59:14 2012 +0200
+++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/SDLActivity.java	Sat Apr 21 18:02:44 2012 +0200
@@ -100,10 +100,6 @@
 		super.onResume();
 	}
 
-	public void onBackPressed(){
-		PascalExports.HWterminate(true);
-	}
-
 	protected void onDestroy() {
 		super.onDestroy();
 		Log.v("SDL", "onDestroy()");
@@ -480,14 +476,14 @@
 		Log.v("SDL", "surfaceCreated()");
 		holder.setType(SurfaceHolder.SURFACE_TYPE_GPU);
 		SDLActivity.createEGLSurface();
-//		enableSensor(Sensor.TYPE_ACCELEROMETER, true);
+		//		enableSensor(Sensor.TYPE_ACCELEROMETER, true);
 	}
 
 	// Called when we lose the surface
 	public void surfaceDestroyed(SurfaceHolder holder) {
 		Log.v("SDL", "surfaceDestroyed()");
 		SDLActivity.nativePause();
-//		enableSensor(Sensor.TYPE_ACCELEROMETER, false);
+		//		enableSensor(Sensor.TYPE_ACCELEROMETER, false);
 	}
 
 	// Called when the surface is resized
@@ -553,7 +549,15 @@
 
 	// Key events
 	public boolean onKey(View  v, int keyCode, KeyEvent event) {
-		if(keyCode == KeyEvent.KEYCODE_BACK) return false;
+		switch(keyCode){
+		case KeyEvent.KEYCODE_BACK:
+		        PascalExports.HWterminate(true);
+                        return true;
+		case KeyEvent.KEYCODE_VOLUME_DOWN:
+		case KeyEvent.KEYCODE_VOLUME_UP:
+		case KeyEvent.KEYCODE_VOLUME_MUTE:
+			return false;
+		}
 		if (event.getAction() == KeyEvent.ACTION_DOWN) {
 			//Log.v("SDL", "key down: " + keyCode);
 			SDLActivity.onNativeKeyDown(keyCode);