5454import android .view .ViewGroup .LayoutParams ;
5555import android .widget .*;
5656import android .app .Fragment ;
57+ import android .view .WindowManager ;
58+ import android .view .Display ;
5759
5860import processing .data .*;
5961import processing .event .*;
@@ -463,7 +465,28 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
463465 activity = getActivity ();
464466 View rootView ;
465467
468+ Point size = new Point ();
469+ WindowManager wm = (WindowManager )activity .getSystemService (Context .WINDOW_SERVICE );
470+ Display display = wm .getDefaultDisplay ();
471+ if (SDK >= 17 ) {
472+ display .getRealSize (size );
473+ } else if (SDK >= 14 ) {
474+ // Use undocumented methods getRawWidth, getRawHeight
475+ try {
476+ size .x = (Integer ) Display .class .getMethod ("getRawWidth" ).invoke (display );
477+ size .y = (Integer ) Display .class .getMethod ("getRawHeight" ).invoke (display );
478+ } catch (Exception e ) {
479+ display .getSize (size );
480+ }
481+ }
482+ displayWidth = size .x ;
483+ displayHeight = size .y ;
466484 handleSettings ();
485+ if (fullScreen ) {
486+ // Setting the default height and width to be fullscreen
487+ width = displayWidth ;
488+ height = displayHeight ;
489+ }
467490
468491 // Get renderer name and class
469492 String rendererName = sketchRenderer ();
@@ -477,15 +500,13 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
477500 }
478501
479502 // Dummy values for initialization, setSize() will be called later onSurfaceChanged()
480- int sw = 0 ;
481- int sh = 0 ;
482503 if (rendererName .equals (JAVA2D )) {
483504 // JAVA2D renderer
484- surfaceView = new SketchSurfaceView (activity , sw , sh ,
505+ surfaceView = new SketchSurfaceView (activity , width , height ,
485506 (Class <? extends PGraphicsAndroid2D >) rendererClass );
486507 } else if (PGraphicsOpenGL .class .isAssignableFrom (rendererClass )) {
487508 // P2D, P3D, and any other PGraphicsOpenGL-based renderer
488- surfaceView = new SketchSurfaceViewGL (activity , sw , sh ,
509+ surfaceView = new SketchSurfaceViewGL (activity , width , height ,
489510 (Class <? extends PGraphicsOpenGL >) rendererClass );
490511 } else {
491512 // Anything else
@@ -496,6 +517,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
496517
497518 setFullScreenVisibility ();
498519
520+ /*
499521 // Getting the display metrics only after setting fullscreen mode
500522 DisplayMetrics dm = new DisplayMetrics();
501523 activity.getWindowManager().getDefaultDisplay().getMetrics(dm);
@@ -504,13 +526,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
504526// println("density is " + dm.density);
505527// println("densityDpi is " + dm.densityDpi);
506528 if (DEBUG) println("display metrics: " + dm);
507-
508- if (fullScreen ) {
509- // Setting the default height and width to be fullscreen
510- width = displayWidth ;
511- height = displayHeight ;
512- }
513-
529+ */
514530
515531 //set smooth level
516532 if (smooth == 0 ) {
0 commit comments