-
Notifications
You must be signed in to change notification settings - Fork 3.4k
[webview_flutter] Add support for payment requests on Android #9679
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mataku
wants to merge
23
commits into
flutter:main
Choose a base branch
from
mataku:feature/expose-payment-request-enabled
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+843
−1
Open
Changes from 7 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
2d07746
Add wrapper for androidx.webkit.WebSettingsCompat
mataku 1a01f13
Add wrapper for androidx.webkit.WebViewFeature
mataku d098b47
Expose wrappers
mataku 8fa5fe1
Add native unit tests for payment request feature
mataku 381ae6f
Add sample menu for payment request
mataku 5eee7b3
Prepare CHANGELOG
mataku d43bde1
Run auto-formatter
mataku a20f0fb
Simplify method description
mataku 103e29f
Specify details with added methods
mataku 8c73517
Fix RequiresFeature lint: setPaymentRequestEnabled should only be cal…
mataku 5ed43ab
Fix format
mataku 28f8889
Fix doc comments to correspond to the method
mataku 3f68c0e
Remove sample for WebSettingsCompat and WebViewFeature.
mataku 878fd38
Update generated files according to comment update
mataku b0388bc
Specify collect type
mataku 5f7f689
Merge main into feature/expose-payment-request-enabled
mataku ddea6d4
Client should use setPaymentRequestEnabled if only WebViewFeatureProx…
mataku 2b06e3d
Add Payment Request section for webview_flutter_android
mataku 69c8a3e
Merge branch upstream/main into feature/expose-payment-request-enabled
mataku 7337199
Fix tests according to SuppressLint
mataku 47b6b6f
Address code-excerpt
mataku 1cb2a20
Run update-excerpts
mataku 5575248
Minor README wording changes
stuartmorgan-g File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
packages/webview_flutter/webview_flutter_android/CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
## 4.9.0 | ||
|
||
* Adds support to check payment request is supported. | ||
|
||
## 4.8.2 | ||
|
||
* Bumps gradle from 8.9.0 to 8.11.1. | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...id/android/src/main/java/io/flutter/plugins/webviewflutter/WebSettingsCompatProxyApi.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,25 @@ | ||||||||||||||||||||||||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||||||||||||||||||||||||
// Use of this source code is governed by a BSD-style license that can be | ||||||||||||||||||||||||
// found in the LICENSE file. | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
package io.flutter.plugins.webviewflutter; | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
import android.webkit.WebSettings; | ||||||||||||||||||||||||
import androidx.annotation.NonNull; | ||||||||||||||||||||||||
import androidx.webkit.WebSettingsCompat; | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
/** | ||||||||||||||||||||||||
* Host api implementation for {@link WebSettingsCompat}. | ||||||||||||||||||||||||
* | ||||||||||||||||||||||||
* <p>Handles static methods for {@link WebSettingsCompat}. | ||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like this was copied from the other api implementations which are actually incorrect. You can change this to:
Suggested change
|
||||||||||||||||||||||||
public class WebSettingsCompatProxyApi extends PigeonApiWebSettingsCompat { | ||||||||||||||||||||||||
public WebSettingsCompatProxyApi(@NonNull ProxyApiRegistrar pigeonRegistrar) { | ||||||||||||||||||||||||
super(pigeonRegistrar); | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
@Override | ||||||||||||||||||||||||
public void setPaymentRequestEnabled(@NonNull WebSettings webSettings, boolean enabled) { | ||||||||||||||||||||||||
WebSettingsCompat.setPaymentRequestEnabled(webSettings, enabled); | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
} |
24 changes: 24 additions & 0 deletions
24
...droid/android/src/main/java/io/flutter/plugins/webviewflutter/WebViewFeatureProxyApi.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,24 @@ | ||||||||||||||||||||||||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||||||||||||||||||||||||
// Use of this source code is governed by a BSD-style license that can be | ||||||||||||||||||||||||
// found in the LICENSE file. | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
package io.flutter.plugins.webviewflutter; | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
import androidx.annotation.NonNull; | ||||||||||||||||||||||||
import androidx.webkit.WebViewFeature; | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
/** | ||||||||||||||||||||||||
* Host api implementation for {@link WebViewFeature}. | ||||||||||||||||||||||||
* | ||||||||||||||||||||||||
* <p>Handles creating {@link WebViewFeature}s that intercommunicate with a paired Dart object. | ||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same for here:
Suggested change
|
||||||||||||||||||||||||
public class WebViewFeatureProxyApi extends PigeonApiWebViewFeature { | ||||||||||||||||||||||||
public WebViewFeatureProxyApi(@NonNull ProxyApiRegistrar pigeonRegistrar) { | ||||||||||||||||||||||||
super(pigeonRegistrar); | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
@Override | ||||||||||||||||||||||||
public boolean isFeatureSupported(@NonNull String feature) { | ||||||||||||||||||||||||
return WebViewFeature.isFeatureSupported(feature); | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
} |
30 changes: 30 additions & 0 deletions
30
...ndroid/android/src/test/java/io/flutter/plugins/webviewflutter/WebSettingsCompatTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
package io.flutter.plugins.webviewflutter; | ||
|
||
import static org.junit.Assert.fail; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.mockStatic; | ||
|
||
import android.webkit.WebSettings; | ||
import androidx.webkit.WebSettingsCompat; | ||
import org.junit.Test; | ||
import org.mockito.MockedStatic; | ||
|
||
public class WebSettingsCompatTest { | ||
@Test | ||
public void setPaymentRequestEnabled() { | ||
final PigeonApiWebSettingsCompat api = | ||
new TestProxyApiRegistrar().getPigeonApiWebSettingsCompat(); | ||
|
||
final WebSettings webSettings = mock(WebSettings.class); | ||
try (MockedStatic<WebSettingsCompat> mockedStatic = mockStatic(WebSettingsCompat.class)) { | ||
api.setPaymentRequestEnabled(webSettings, true); | ||
mockedStatic.verify(() -> WebSettingsCompat.setPaymentRequestEnabled(webSettings, true)); | ||
} catch (Exception e) { | ||
fail(e.toString()); | ||
} | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
...r_android/android/src/test/java/io/flutter/plugins/webviewflutter/WebViewFeatureTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
package io.flutter.plugins.webviewflutter; | ||
|
||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertTrue; | ||
import static org.junit.Assert.fail; | ||
import static org.mockito.Mockito.mockStatic; | ||
|
||
import androidx.webkit.WebViewFeature; | ||
import org.junit.Test; | ||
import org.mockito.MockedStatic; | ||
|
||
public class WebViewFeatureTest { | ||
@Test | ||
public void isFeatureSupported() { | ||
final PigeonApiWebViewFeature api = new TestProxyApiRegistrar().getPigeonApiWebViewFeature(); | ||
|
||
try (MockedStatic<WebViewFeature> mockedStatic = mockStatic(WebViewFeature.class)) { | ||
mockedStatic | ||
.when(() -> WebViewFeature.isFeatureSupported("PAYMENT_REQUEST")) | ||
.thenReturn(true); | ||
|
||
boolean result = api.isFeatureSupported("PAYMENT_REQUEST"); | ||
|
||
assertTrue(result); | ||
|
||
mockedStatic.verify(() -> WebViewFeature.isFeatureSupported("PAYMENT_REQUEST")); | ||
} catch (Exception e) { | ||
fail(e.toString()); | ||
} | ||
} | ||
|
||
@Test | ||
public void isFeatureSupportedReturnsFalse() { | ||
final PigeonApiWebViewFeature api = new TestProxyApiRegistrar().getPigeonApiWebViewFeature(); | ||
|
||
try (MockedStatic<WebViewFeature> mockedStatic = mockStatic(WebViewFeature.class)) { | ||
mockedStatic | ||
.when(() -> WebViewFeature.isFeatureSupported("UNSUPPORTED_FEATURE")) | ||
.thenReturn(false); | ||
|
||
boolean result = api.isFeatureSupported("UNSUPPORTED_FEATURE"); | ||
|
||
assertFalse(result); | ||
|
||
mockedStatic.verify(() -> WebViewFeature.isFeatureSupported("UNSUPPORTED_FEATURE")); | ||
} catch (Exception e) { | ||
fail(e.toString()); | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This changelog entry could be more descriptive and follow the repository's style guide more closely (e.g., complete sentence, ending with a period, using code formatting for API names).