54
54
import android .view .ViewGroup .LayoutParams ;
55
55
import android .widget .*;
56
56
import android .app .Fragment ;
57
+ import android .view .WindowManager ;
58
+ import android .view .Display ;
57
59
58
60
import processing .data .*;
59
61
import processing .event .*;
@@ -463,7 +465,28 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
463
465
activity = getActivity ();
464
466
View rootView ;
465
467
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 ;
466
484
handleSettings ();
485
+ if (fullScreen ) {
486
+ // Setting the default height and width to be fullscreen
487
+ width = displayWidth ;
488
+ height = displayHeight ;
489
+ }
467
490
468
491
// Get renderer name and class
469
492
String rendererName = sketchRenderer ();
@@ -477,15 +500,13 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
477
500
}
478
501
479
502
// Dummy values for initialization, setSize() will be called later onSurfaceChanged()
480
- int sw = 0 ;
481
- int sh = 0 ;
482
503
if (rendererName .equals (JAVA2D )) {
483
504
// JAVA2D renderer
484
- surfaceView = new SketchSurfaceView (activity , sw , sh ,
505
+ surfaceView = new SketchSurfaceView (activity , width , height ,
485
506
(Class <? extends PGraphicsAndroid2D >) rendererClass );
486
507
} else if (PGraphicsOpenGL .class .isAssignableFrom (rendererClass )) {
487
508
// P2D, P3D, and any other PGraphicsOpenGL-based renderer
488
- surfaceView = new SketchSurfaceViewGL (activity , sw , sh ,
509
+ surfaceView = new SketchSurfaceViewGL (activity , width , height ,
489
510
(Class <? extends PGraphicsOpenGL >) rendererClass );
490
511
} else {
491
512
// Anything else
@@ -496,6 +517,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
496
517
497
518
setFullScreenVisibility ();
498
519
520
+ /*
499
521
// Getting the display metrics only after setting fullscreen mode
500
522
DisplayMetrics dm = new DisplayMetrics();
501
523
activity.getWindowManager().getDefaultDisplay().getMetrics(dm);
@@ -504,13 +526,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
504
526
// println("density is " + dm.density);
505
527
// println("densityDpi is " + dm.densityDpi);
506
528
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
+ */
514
530
515
531
//set smooth level
516
532
if (smooth == 0 ) {
0 commit comments