1919import android .webkit .WebView ;
2020import android .widget .RelativeLayout ;
2121import androidx .annotation .Nullable ;
22+ import java .util .HashMap ;
2223import java .util .Map ;
2324import java .util .Objects ;
2425import java .util .concurrent .ConcurrentHashMap ;
@@ -46,7 +47,7 @@ protected void onCreate(Bundle savedInstanceState) {
4647
4748 // there is a stripe at the top of the screen for contents
4849 // we eliminate it with hiding the system ui
49- hideSystemUI ( );
50+ getWindow (). getDecorView (). setSystemUiVisibility ( View . SYSTEM_UI_FLAG_LAYOUT_STABLE );
5051 super .onCreate (savedInstanceState );
5152 overridePendingTransition (0 , 0 );
5253
@@ -76,7 +77,8 @@ protected void onCreate(Bundle savedInstanceState) {
7677 params .y = config .y ;
7778 params .height = config .height ;
7879 params .width = config .width ;
79- params .flags = WindowManager .LayoutParams .FLAG_NOT_FOCUSABLE ;
80+ params .flags = WindowManager .LayoutParams .FLAG_NOT_TOUCH_MODAL
81+ | WindowManager .LayoutParams .FLAG_WATCH_OUTSIDE_TOUCH ;
8082 getWindow ().setAttributes (params );
8183 getWindow ().setBackgroundDrawableResource (android .R .color .transparent );
8284
@@ -91,18 +93,6 @@ protected void onCreate(Bundle savedInstanceState) {
9193 setContentView (relativeLayout );
9294 }
9395
94- private void hideSystemUI () {
95- // Enables regular immersive mode
96- getWindow ().getDecorView ().setSystemUiVisibility (
97- View .SYSTEM_UI_FLAG_IMMERSIVE_STICKY
98- | View .SYSTEM_UI_FLAG_LAYOUT_STABLE
99- | View .SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
100- | View .SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
101- | View .SYSTEM_UI_FLAG_HIDE_NAVIGATION
102- | View .SYSTEM_UI_FLAG_FULLSCREEN
103- );
104- }
105-
10696 private TransparentActivityConfig setupConfig (@ Nullable TransparentActivityConfig config ) {
10797 final WindowManager wm = (WindowManager ) getSystemService (Context .WINDOW_SERVICE );
10898 final Display display = wm .getDefaultDisplay ();
@@ -392,6 +382,7 @@ private void close(Map<String, Object> contentData) {
392382 @ SuppressLint ("SetJavaScriptEnabled" )
393383 private WebView createWebView (TransparentActivityConfig config ) {
394384 WebView webView = new CountlyWebView (this );
385+ webView .setVisibility (View .INVISIBLE );
395386 RelativeLayout .LayoutParams webLayoutParams = new RelativeLayout .LayoutParams (config .width , config .height );
396387 webLayoutParams .addRule (RelativeLayout .ALIGN_PARENT_BOTTOM );
397388 webLayoutParams .addRule (RelativeLayout .ALIGN_PARENT_END );
@@ -423,7 +414,17 @@ private WebView createWebView(TransparentActivityConfig config) {
423414 return false ;
424415 }
425416 });
417+ client .afterPageFinished = (closeIt ) -> {
418+ if (closeIt ) {
419+ close (new HashMap <>());
426420
421+ if (Countly .sharedInstance ().isInitialized ()) {
422+ Countly .sharedInstance ().moduleContent .notifyAfterContentIsClosed ();
423+ }
424+ } else {
425+ webView .setVisibility (View .VISIBLE );
426+ }
427+ };
427428 webView .setWebViewClient (client );
428429 webView .loadUrl (config .url );
429430 return webView ;
0 commit comments