Added Android direct camera capture feature
This commit is contained in:
parent
25cb58dce7
commit
6abf958b31
|
@ -1,5 +1,6 @@
|
||||||
## 5.4.4+4
|
## 5.4.5
|
||||||
|
|
||||||
|
- Added Android direct camera capture feature
|
||||||
- Fixed missing `PullToRefreshController.isRefreshing` iOS implementation
|
- Fixed missing `PullToRefreshController.isRefreshing` iOS implementation
|
||||||
- Fixed Android `PullToRefreshController.setEnabled` at runtime
|
- Fixed Android `PullToRefreshController.setEnabled` at runtime
|
||||||
- Fixed iOS `findNext`
|
- Fixed iOS `findNext`
|
||||||
|
|
|
@ -780,15 +780,15 @@ public class InAppWebViewChromeClient extends WebChromeClient implements PluginR
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void openFileChooser(ValueCallback<Uri> filePathCallback, String acceptType) {
|
protected void openFileChooser(ValueCallback<Uri> filePathCallback, String acceptType) {
|
||||||
startPhotoPickerIntent(filePathCallback, acceptType);
|
startPickerIntent(filePathCallback, acceptType, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void openFileChooser(ValueCallback<Uri> filePathCallback) {
|
protected void openFileChooser(ValueCallback<Uri> filePathCallback) {
|
||||||
startPhotoPickerIntent(filePathCallback, "");
|
startPickerIntent(filePathCallback, "", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void openFileChooser(ValueCallback<Uri> filePathCallback, String acceptType, String capture) {
|
protected void openFileChooser(ValueCallback<Uri> filePathCallback, String acceptType, String capture) {
|
||||||
startPhotoPickerIntent(filePathCallback, acceptType);
|
startPickerIntent(filePathCallback, acceptType, capture);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||||
|
@ -796,8 +796,8 @@ public class InAppWebViewChromeClient extends WebChromeClient implements PluginR
|
||||||
public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, FileChooserParams fileChooserParams) {
|
public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, FileChooserParams fileChooserParams) {
|
||||||
String[] acceptTypes = fileChooserParams.getAcceptTypes();
|
String[] acceptTypes = fileChooserParams.getAcceptTypes();
|
||||||
boolean allowMultiple = fileChooserParams.getMode() == WebChromeClient.FileChooserParams.MODE_OPEN_MULTIPLE;
|
boolean allowMultiple = fileChooserParams.getMode() == WebChromeClient.FileChooserParams.MODE_OPEN_MULTIPLE;
|
||||||
Intent intent = fileChooserParams.createIntent();
|
boolean captureEnabled = fileChooserParams.isCaptureEnabled();
|
||||||
return startPhotoPickerIntent(filePathCallback, intent, acceptTypes, allowMultiple);
|
return startPickerIntent(filePathCallback, acceptTypes, allowMultiple, captureEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -898,58 +898,89 @@ public class InAppWebViewChromeClient extends WebChromeClient implements PluginR
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startPhotoPickerIntent(ValueCallback<Uri> filePathCallback, String acceptType) {
|
public void startPickerIntent(ValueCallback<Uri> filePathCallback, String acceptType, @Nullable String capture) {
|
||||||
InAppWebViewFlutterPlugin.filePathCallbackLegacy = filePathCallback;
|
InAppWebViewFlutterPlugin.filePathCallbackLegacy = filePathCallback;
|
||||||
|
|
||||||
Intent fileChooserIntent = getFileChooserIntent(acceptType);
|
boolean images = acceptsImages(acceptType);
|
||||||
Intent chooserIntent = Intent.createChooser(fileChooserIntent, "");
|
boolean video = acceptsVideo(acceptType);
|
||||||
|
|
||||||
ArrayList<Parcelable> extraIntents = new ArrayList<>();
|
Intent pickerIntent = null;
|
||||||
if (acceptsImages(acceptType)) {
|
|
||||||
extraIntents.add(getPhotoIntent());
|
if (capture != null) {
|
||||||
|
if (!needsCameraPermission()) {
|
||||||
|
if (images) {
|
||||||
|
pickerIntent = getPhotoIntent();
|
||||||
|
}
|
||||||
|
else if (video) {
|
||||||
|
pickerIntent = getVideoIntent();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (acceptsVideo(acceptType)) {
|
if (pickerIntent == null) {
|
||||||
extraIntents.add(getVideoIntent());
|
Intent fileChooserIntent = getFileChooserIntent(acceptType);
|
||||||
|
pickerIntent = Intent.createChooser(fileChooserIntent, "");
|
||||||
|
|
||||||
|
ArrayList<Parcelable> extraIntents = new ArrayList<>();
|
||||||
|
if (!needsCameraPermission()) {
|
||||||
|
if (images) {
|
||||||
|
extraIntents.add(getPhotoIntent());
|
||||||
|
}
|
||||||
|
if (video) {
|
||||||
|
extraIntents.add(getVideoIntent());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pickerIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, extraIntents.toArray(new Parcelable[]{}));
|
||||||
}
|
}
|
||||||
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, extraIntents.toArray(new Parcelable[]{}));
|
|
||||||
|
|
||||||
Activity activity = getActivity();
|
Activity activity = getActivity();
|
||||||
if (activity == null) {
|
if (activity != null && pickerIntent.resolveActivity(activity.getPackageManager()) != null) {
|
||||||
return;
|
activity.startActivityForResult(pickerIntent, PICKER_LEGACY);
|
||||||
}
|
|
||||||
if (chooserIntent.resolveActivity(activity.getPackageManager()) != null) {
|
|
||||||
activity.startActivityForResult(chooserIntent, PICKER_LEGACY);
|
|
||||||
} else {
|
} else {
|
||||||
Log.d(LOG_TAG, "there is no Activity to handle this Intent");
|
Log.d(LOG_TAG, "there is no Activity to handle this Intent");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||||
public boolean startPhotoPickerIntent(final ValueCallback<Uri[]> callback, final Intent intent, final String[] acceptTypes, final boolean allowMultiple) {
|
public boolean startPickerIntent(final ValueCallback<Uri[]> callback, final String[] acceptTypes,
|
||||||
|
final boolean allowMultiple, final boolean captureEnabled) {
|
||||||
InAppWebViewFlutterPlugin.filePathCallback = callback;
|
InAppWebViewFlutterPlugin.filePathCallback = callback;
|
||||||
|
|
||||||
ArrayList<Parcelable> extraIntents = new ArrayList<>();
|
boolean images = acceptsImages(acceptTypes);
|
||||||
if (!needsCameraPermission()) {
|
boolean video = acceptsVideo(acceptTypes);
|
||||||
if (acceptsImages(acceptTypes)) {
|
|
||||||
extraIntents.add(getPhotoIntent());
|
Intent pickerIntent = null;
|
||||||
}
|
|
||||||
if (acceptsVideo(acceptTypes)) {
|
if (captureEnabled) {
|
||||||
extraIntents.add(getVideoIntent());
|
if (!needsCameraPermission()) {
|
||||||
|
if (images) {
|
||||||
|
pickerIntent = getPhotoIntent();
|
||||||
|
}
|
||||||
|
else if (video) {
|
||||||
|
pickerIntent = getVideoIntent();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (pickerIntent == null) {
|
||||||
|
ArrayList<Parcelable> extraIntents = new ArrayList<>();
|
||||||
|
if (!needsCameraPermission()) {
|
||||||
|
if (images) {
|
||||||
|
extraIntents.add(getPhotoIntent());
|
||||||
|
}
|
||||||
|
if (video) {
|
||||||
|
extraIntents.add(getVideoIntent());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Intent fileSelectionIntent = getFileChooserIntent(acceptTypes, allowMultiple);
|
Intent fileSelectionIntent = getFileChooserIntent(acceptTypes, allowMultiple);
|
||||||
|
|
||||||
Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER);
|
pickerIntent = new Intent(Intent.ACTION_CHOOSER);
|
||||||
chooserIntent.putExtra(Intent.EXTRA_INTENT, fileSelectionIntent);
|
pickerIntent.putExtra(Intent.EXTRA_INTENT, fileSelectionIntent);
|
||||||
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, extraIntents.toArray(new Parcelable[]{}));
|
pickerIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, extraIntents.toArray(new Parcelable[]{}));
|
||||||
|
}
|
||||||
|
|
||||||
Activity activity = getActivity();
|
Activity activity = getActivity();
|
||||||
if (activity == null) {
|
if (activity != null && pickerIntent.resolveActivity(activity.getPackageManager()) != null) {
|
||||||
return true;
|
activity.startActivityForResult(pickerIntent, PICKER);
|
||||||
}
|
|
||||||
if (chooserIntent.resolveActivity(activity.getPackageManager()) != null) {
|
|
||||||
activity.startActivityForResult(chooserIntent, PICKER);
|
|
||||||
} else {
|
} else {
|
||||||
Log.d(LOG_TAG, "there is no Activity to handle this Intent");
|
Log.d(LOG_TAG, "there is no Activity to handle this Intent");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
name: flutter_inappwebview
|
name: flutter_inappwebview
|
||||||
description: A Flutter plugin that allows you to add an inline webview, to use an headless webview, and to open an in-app browser window.
|
description: A Flutter plugin that allows you to add an inline webview, to use an headless webview, and to open an in-app browser window.
|
||||||
version: 5.4.4+4
|
version: 5.4.5
|
||||||
homepage: https://inappwebview.dev/
|
homepage: https://inappwebview.dev/
|
||||||
repository: https://github.com/pichillilorenzo/flutter_inappwebview
|
repository: https://github.com/pichillilorenzo/flutter_inappwebview
|
||||||
issue_tracker: https://github.com/pichillilorenzo/flutter_inappwebview/issues
|
issue_tracker: https://github.com/pichillilorenzo/flutter_inappwebview/issues
|
||||||
|
|
Loading…
Reference in New Issue