Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/url_launcher/url_launcher_android/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## NEXT

* Updates minimum supported SDK version to Flutter 3.38/Dart 3.10.
* Fixes WebView content being obscured by system navigation bar on Android 15+

## 6.3.30

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.core.content.ContextCompat;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -90,6 +93,15 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
webview = new WebView(this);
setContentView(webview);
// Apply system window insets as padding to prevent WebView content
// from being obscured by system bars (e.g. navigation bar) on Android 15+.
ViewCompat.setOnApplyWindowInsetsListener(
webview,
(v, insets) -> {
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
return insets;
});
// Get the Intent that started this activity and extract the string
final Intent intent = getIntent();
final String url = intent.getStringExtra(URL_EXTRA);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,41 @@
// Copyright 2013 The Flutter Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

package io.flutter.plugins.urllauncher;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

import android.os.Bundle;
import androidx.test.core.app.ApplicationProvider;
import java.util.Collections;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;

@RunWith(RobolectricTestRunner.class)
public class WebViewActivityTest {

@Test
public void extractHeaders_returnsEmptyMapWhenHeadersBundleNull() {
assertEquals(WebViewActivity.extractHeaders(null), Collections.emptyMap());
}

@Test
public void onCreate_webviewIsNotNull() {
WebViewActivity activity =
Robolectric.buildActivity(
WebViewActivity.class,
WebViewActivity.createIntent(
ApplicationProvider.getApplicationContext(),
"https://flutter.dev",
false,
false,
new Bundle()))
.create()
.get();
Comment on lines +28 to +37
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The indentation of the Robolectric.buildActivity call is inconsistent with the 2-space indentation used in the project.

    WebViewActivity activity =
        Robolectric.buildActivity(
            WebViewActivity.class,
            WebViewActivity.createIntent(
                ApplicationProvider.getApplicationContext(),
                "https://flutter.dev",
                false,
                false,
                new Bundle()))
            .create()
            .get();
References
  1. Code should follow the relevant style guides for each language (Google Java Style for Java). (link)


assertNotNull(activity.webview);
}
}