This commit is contained in:
Michel Jautzy 2017-06-23 16:27:44 +02:00
parent 294299aa97
commit 6ce2f16963
1 changed files with 23 additions and 7 deletions

View File

@ -15,6 +15,7 @@ import org.apache.cordova.CordovaWebView;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.app.Activity; import android.app.Activity;
import android.os.Build; import android.os.Build;
import android.util.DisplayMetrics;
import android.util.Log; import android.util.Log;
import android.content.Context; import android.content.Context;
@ -105,15 +106,30 @@ public class NavigationBar extends CordovaPlugin {
public void run() { public void run() {
Activity mikeActivity=cordova.getActivity(); //Activity mikeActivity=cordova.getActivity();
Context context=mikeActivity.getApplicationContext(); //Context context=mikeActivity.getApplicationContext();
int resourceId = mikeActivity.getResources().getIdentifier("navigation_bar_height", "dimen", "android"); //int resourceId = mikeActivity.getResources().getIdentifier("navigation_bar_height", "dimen", "android");
int pixelHeight = 0; //int pixelHeight = 0;
if (resourceId > 0) { //if (resourceId > 0) {
pixelHeight = mikeActivity.getResources().getDimensionPixelSize(resourceId); // pixelHeight = mikeActivity.getResources().getDimensionPixelSize(resourceId);
} //}
int pixelHeight = 0;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
DisplayMetrics metrics = new DisplayMetrics();
Activity mikeActivity=cordova.getActivity();
mikeActivity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
int usableHeight = metrics.heightPixels;
mikeActivity.getWindowManager().getDefaultDisplay().getRealMetrics(metrics);
int realHeight = metrics.heightPixels;
if (realHeight > usableHeight){
pixelHeight = realHeight - usableHeight;
}
}
PluginResult pr = new PluginResult(PluginResult.Status.OK, pixelHeight); PluginResult pr = new PluginResult(PluginResult.Status.OK, pixelHeight);
delayedCC.sendPluginResult(pr); delayedCC.sendPluginResult(pr);