This commit is contained in:
Michel Jautzy 2017-06-23 16:04:48 +02:00
parent 57afebfa4e
commit 294299aa97
2 changed files with 186 additions and 144 deletions

View File

@ -16,6 +16,8 @@ import android.annotation.TargetApi;
import android.app.Activity; import android.app.Activity;
import android.os.Build; import android.os.Build;
import android.util.Log; import android.util.Log;
import android.content.Context;
// //
import android.view.View; import android.view.View;
import android.os.Handler; import android.os.Handler;
@ -24,6 +26,7 @@ import java.lang.reflect.Method;
public class NavigationBar extends CordovaPlugin { public class NavigationBar extends CordovaPlugin {
private static final String LOG_TAG = "NavigationBar"; private static final String LOG_TAG = "NavigationBar";
public int pixelHeight = 0;
public void initialize(CordovaInterface cordova, CordovaWebView webView) { public void initialize(CordovaInterface cordova, CordovaWebView webView) {
super.initialize(cordova, webView); super.initialize(cordova, webView);
@ -91,6 +94,34 @@ public class NavigationBar extends CordovaPlugin {
return true; return true;
} }
else if (action.equals("softNavigationHeight")) {
final CallbackContext delayedCC = callbackContext;
cordova.getActivity().runOnUiThread(new Runnable(){
@Override
public void run() {
Activity mikeActivity=cordova.getActivity();
Context context=mikeActivity.getApplicationContext();
int resourceId = mikeActivity.getResources().getIdentifier("navigation_bar_height", "dimen", "android");
int pixelHeight = 0;
if (resourceId > 0) {
pixelHeight = mikeActivity.getResources().getDimensionPixelSize(resourceId);
}
PluginResult pr = new PluginResult(PluginResult.Status.OK, pixelHeight);
delayedCC.sendPluginResult(pr);
}
});
return true;
}
return false; // Returning false results in a "MethodNotFound" error. return false; // Returning false results in a "MethodNotFound" error.
} }
@ -172,3 +203,4 @@ public class NavigationBar extends CordovaPlugin {
); );
} }
} }

View File

@ -17,5 +17,15 @@ module.exports = {
'hideNavigationBar', 'hideNavigationBar',
[] []
); );
},
softNavigationHeight: function(successCallback, errorCallback) {
cordova.exec(
successCallback,
errorCallback,
'NavigationBar',
'softNavigationHeight',
[]
);
} }
}; };