@@ -501,24 +501,29 @@ public void initSurface(LayoutInflater inflater, ViewGroup container,
501
501
502
502
private void setFullScreenVisibility () {
503
503
if (fullScreen ) {
504
- int visibility ;
505
- if (SDK < 19 ) {
506
- // Pre-4.4
507
- visibility = View .SYSTEM_UI_FLAG_HIDE_NAVIGATION ;
508
- } else {
509
- // 4.4 and higher. Integer instead of constants defined in View so it can
510
- // build with SDK < 4.4
511
- visibility = 256 | // View.SYSTEM_UI_FLAG_LAYOUT_STABLE
512
- 512 | // View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
513
- 1024 | // View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
514
- View .SYSTEM_UI_FLAG_HIDE_NAVIGATION |
515
- 4 | // View.SYSTEM_UI_FLAG_FULLSCREEN
516
- 4096 ; // View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
517
- // However, this visibility does not fix a bug where the navigation area
518
- // turns black after resuming the app:
519
- // https://code.google.com/p/android/issues/detail?id=170752
520
- }
521
- surface .setSystemUiVisibility (visibility );
504
+ runOnUiThread (new Runnable () {
505
+ @ Override
506
+ public void run () {
507
+ int visibility ;
508
+ if (SDK < 19 ) {
509
+ // Pre-4.4
510
+ visibility = View .SYSTEM_UI_FLAG_HIDE_NAVIGATION ;
511
+ } else {
512
+ // 4.4 and higher. Integer instead of constants defined in View so it can
513
+ // build with SDK < 4.4
514
+ visibility = 256 | // View.SYSTEM_UI_FLAG_LAYOUT_STABLE
515
+ 512 | // View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
516
+ 1024 | // View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
517
+ View .SYSTEM_UI_FLAG_HIDE_NAVIGATION |
518
+ 4 | // View.SYSTEM_UI_FLAG_FULLSCREEN
519
+ 4096 ; // View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
520
+ // However, this visibility does not fix a bug where the navigation area
521
+ // turns black after resuming the app:
522
+ // https://code.google.com/p/android/issues/detail?id=170752
523
+ }
524
+ surface .setSystemUiVisibility (visibility );
525
+ }
526
+ });
522
527
}
523
528
}
524
529
@@ -557,6 +562,9 @@ public void onResume() {
557
562
public void onPause () {
558
563
surface .pauseThread ();
559
564
565
+ // Make sure that the keyboard is not left open after leaving the app
566
+ closeKeyboard ();
567
+
560
568
// TODO need to save all application state here!
561
569
// At least we save the current style (once we had at least drawn one
562
570
// frame, otherwise we might be saving a "null" style with all zeroes).
@@ -2156,8 +2164,8 @@ protected void nativeMotionEvent(MotionEvent motionEvent) {
2156
2164
button = state ;
2157
2165
}
2158
2166
2159
- enqueueTouchEvents (motionEvent , button , modifiers );
2160
2167
enqueueMouseEvents (motionEvent , button , modifiers );
2168
+ enqueueTouchEvents (motionEvent , button , modifiers );
2161
2169
}
2162
2170
2163
2171
@@ -2504,6 +2512,9 @@ public void closeKeyboard() {
2504
2512
Context context = surface .getContext ();
2505
2513
InputMethodManager imm = (InputMethodManager )context .getSystemService (Context .INPUT_METHOD_SERVICE );
2506
2514
imm .toggleSoftInput (InputMethodManager .HIDE_IMPLICIT_ONLY , 0 );
2515
+ if (parentLayout == -1 ) {
2516
+ setFullScreenVisibility ();
2517
+ }
2507
2518
}
2508
2519
2509
2520
0 commit comments