@@ -28,14 +28,17 @@ Licensed to the Apache Software Foundation (ASF) under one
28
28
import android .graphics .PorterDuff ;
29
29
import android .graphics .PorterDuffColorFilter ;
30
30
import android .graphics .Color ;
31
+ import android .graphics .Point ;
31
32
import android .net .Uri ;
32
33
import android .os .Build ;
33
34
import android .os .Bundle ;
34
35
import android .text .InputType ;
35
36
import android .util .TypedValue ;
37
+ import android .view .Display ;
36
38
import android .view .Gravity ;
37
39
import android .view .KeyEvent ;
38
40
import android .view .View ;
41
+ import android .view .ViewGroup ;
39
42
import android .view .Window ;
40
43
import android .view .WindowManager ;
41
44
import android .view .WindowManager .LayoutParams ;
@@ -648,6 +651,27 @@ private int dpToPixels(int dipValue) {
648
651
return value ;
649
652
}
650
653
654
+ private int getDisplayContentHeight () {
655
+ final WindowManager windowManager = cordova .getActivity ().getWindowManager ();
656
+ final Point size = new Point ();
657
+ int screenHeight = 0 , actionBarHeight = 0 ;
658
+
659
+ if (cordova .getActivity ().getActionBar () != null ) {
660
+ actionBarHeight = cordova .getActivity ().getActionBar ().getHeight ();
661
+ }
662
+
663
+ int contentTop = ((ViewGroup ) cordova .getActivity ().findViewById (android .R .id .content )).getTop ();
664
+
665
+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .HONEYCOMB ) {
666
+ windowManager .getDefaultDisplay ().getSize (size );
667
+ screenHeight = size .y ;
668
+ } else {
669
+ Display d = windowManager .getDefaultDisplay ();
670
+ screenHeight = d .getHeight ();
671
+ }
672
+ return screenHeight - contentTop - actionBarHeight ;
673
+ }
674
+
651
675
private View createCloseButton (int id ){
652
676
View _close ;
653
677
Resources activityRes = cordova .getActivity ().getResources ();
@@ -716,6 +740,9 @@ public void run() {
716
740
717
741
// Toolbar layout
718
742
RelativeLayout toolbar = new RelativeLayout (cordova .getActivity ());
743
+
744
+ boolean showToolbar = getShowLocationBar ();
745
+
719
746
//Please, no more black!
720
747
toolbar .setBackgroundColor (toolbarColor );
721
748
toolbar .setLayoutParams (new RelativeLayout .LayoutParams (LayoutParams .MATCH_PARENT , this .dpToPixels (44 )));
@@ -832,16 +859,31 @@ public boolean onKey(View v, int keyCode, KeyEvent event) {
832
859
View footerClose = createCloseButton (7 );
833
860
footer .addView (footerClose );
834
861
862
+ // Display display = cordova.getActivity().getWindowManager().getDefaultDisplay();
863
+ // Point size = new Point();
864
+ // display.getSize(size);
865
+ // // int width = size.x;
866
+ // int height = size.y;
867
+
868
+ int webViewHeight = getDisplayContentHeight ();
869
+
870
+ if (showToolbar ) {
871
+ webViewHeight = webViewHeight - this .dpToPixels (44 );
872
+ }
873
+
874
+ if (showFooter ) {
875
+ webViewHeight = webViewHeight - footerSize ;
876
+ }
835
877
836
878
// WebView
837
879
inAppWebView = new WebView (cordova .getActivity ());
838
880
// inAppWebView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
839
881
840
- LinearLayout .LayoutParams webViewLayoutParams = new LinearLayout .LayoutParams (LayoutParams .MATCH_PARENT , LayoutParams . MATCH_PARENT );
882
+ LinearLayout .LayoutParams webViewLayoutParams = new LinearLayout .LayoutParams (LayoutParams .MATCH_PARENT , webViewHeight );
841
883
842
- if (showFooter ) {
843
- webViewLayoutParams .setMargins (0 , 0 , 0 , footerSize ) ; // Adding margin the same size as the footer
844
- }
884
+ // if (showFooter) {
885
+ // webViewLayoutParams.setMargins(0, 0, 0, footerSize + this.dpToPixels(16)) ; // Adding margin the same size as the footer plus footer padding
886
+ // }
845
887
846
888
inAppWebView .setLayoutParams (webViewLayoutParams );
847
889
inAppWebView .setId (Integer .valueOf (6 ));
@@ -947,7 +989,7 @@ public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType)
947
989
if (!hideUrlBar ) toolbar .addView (edittext );
948
990
949
991
// Don't add the toolbar if its been disabled
950
- if (getShowLocationBar () ) {
992
+ if (showToolbar ) {
951
993
// Add our toolbar to our main view/layout
952
994
main .addView (toolbar );
953
995
}
@@ -1268,4 +1310,4 @@ public void onReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler, Str
1268
1310
super .onReceivedHttpAuthRequest (view , handler , host , realm );
1269
1311
}
1270
1312
}
1271
- }
1313
+ }
0 commit comments