dpa99c commented on a change in pull request #700:
URL:
https://github.com/apache/cordova-plugin-inappbrowser/pull/700#discussion_r481247407
##########
File path: src/android/InAppBrowser.java
##########
@@ -945,23 +855,96 @@ public boolean onKey(View v, int keyCode, KeyEvent event)
{
// For Android 5.0+
public boolean onShowFileChooser (WebView webView,
ValueCallback<Uri[]> filePathCallback, WebChromeClient.FileChooserParams
fileChooserParams)
{
+ if(Build.VERSION.SDK_INT >=23 &&
(cordova.getActivity().checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED ||
cordova.getActivity().checkSelfPermission(Manifest.permission.CAMERA) !=
PackageManager.PERMISSION_GRANTED)) {
+ cordova.getActivity().requestPermissions(new
String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.CAMERA}, 1);
+ }
+
LOG.d(LOG_TAG, "File Chooser 5.0+");
+
// If callback exists, finish it.
if(mUploadCallbackLollipop != null) {
mUploadCallbackLollipop.onReceiveValue(null);
}
mUploadCallbackLollipop = filePathCallback;
+ Intent takePictureIntent = new
Intent(MediaStore.ACTION_IMAGE_CAPTURE);
+
+
if(takePictureIntent.resolveActivity(cordova.getActivity().getPackageManager())
!= null) {
+
+ File photoFile = null;
+ Uri photoUri = null;
+
+ if (isAndroidQ) {
+ // Android Q compatibility
+ photoUri = createImageUri();
+ mCameraUri = photoUri;
+ if (photoUri != null) {
+
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri);
+ }
+ } else {
+ try {
+ photoFile = createImageFile();
+ takePictureIntent.putExtra("PhotoPath",
mCM);
+ } catch (IOException ex) {
+ Log.e(LOG_TAG, "Image file creation
failed", ex);
+ }
+ if (photoFile != null) {
+ mCM = "file:" +
photoFile.getAbsolutePath();
+
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile));
+ } else {
+ takePictureIntent = null;
+ }
+ }
+ }
// Create File Chooser Intent
- Intent content = new Intent(Intent.ACTION_GET_CONTENT);
- content.addCategory(Intent.CATEGORY_OPENABLE);
- content.setType("*/*");
+ Intent contentSelectionIntent = new
Intent(Intent.ACTION_GET_CONTENT);
+
contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE);
+ contentSelectionIntent.setType("*/*");
+ Intent[] intentArray;
+ if(takePictureIntent != null){
+ intentArray = new Intent[]{takePictureIntent};
+ }else{
+ intentArray = new Intent[0];
+ }
+
+ Locale localeInfo =
cordova.getActivity().getApplicationContext().getResources()
+ .getConfiguration().getLocales().get(0);
+
+ String lang = localeInfo.toLanguageTag();
+
+ String title;
+
+ if (lang.startsWith("en"))
+ {
+ title = "Choose the source";
Review comment:
Adding hard-coded strings such as this is undesirable - better to let
the plugin user pass in a string in their locale
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]