Add hook for getSoftKeyboardHeight on Android (legacy)

This commit is contained in:
Joshua Granick
2015-02-25 14:38:27 -08:00
parent e977b5c551
commit 27d767cfc8

View File

@@ -8,6 +8,7 @@ import android.content.res.Configuration;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Rect;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
@@ -23,6 +24,7 @@ import android.util.Log;
import android.view.inputmethod.InputMethodManager;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.Window;
import android.view.WindowManager;
import dalvik.system.DexClassLoader;
@@ -72,6 +74,7 @@ public class GameActivity extends Activity implements SensorEventListener {
private static float[] orientData = new float[3];
private static float[] rotationMatrix = new float[16];
private static SensorManager sensorManager;
private static Rect mVisibleRect = new Rect ();
public Handler mHandler;
@@ -127,6 +130,16 @@ public class GameActivity extends Activity implements SensorEventListener {
}
mView.getViewTreeObserver ().addOnGlobalLayoutListener (new ViewTreeObserver.OnGlobalLayoutListener () {
@Override public void onGlobalLayout () {
activity.getWindow().getDecorView().getWindowVisibleDisplayFrame (mVisibleRect);
}
});
Extension.packageName = getApplicationContext ().getPackageName ();
if (extensions == null) {
@@ -319,6 +332,23 @@ public class GameActivity extends Activity implements SensorEventListener {
}
public static float getSoftKeyboardHeight () {
float height = Extension.mainView.getHeight () - mVisibleRect.height ();
if (height < 0) {
return 0;
} else {
return height;
}
}
static public String getSpecialDir (int inWhich) {
//Log.v ("GameActivity", "Get special Dir " + inWhich);