Skip to content
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

Fix ipad crush on iOS #247

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
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
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ The plugin conforms to the Cordova plugin specification, it can be installed
using the Cordova / Phonegap command line interface.

# without desc
phonegap plugin add https://github.com/Telerik-Verified-Plugins/ImagePicker.git
cordova plugin add https://github.com/Telerik-Verified-Plugins/ImagePicker.git
phonegap plugin add https://github.com/VerianMobile/ImagePicker.git
cordova plugin add https://github.com/VerianMobile/ImagePicker.git

# with desc
phonegap plugin add https://github.com/Telerik-Verified-Plugins/ImagePicker.git --variable PHOTO_LIBRARY_USAGE_DESCRIPTION="your usage message"
phonegap plugin add https://github.com/VerianMobile/ImagePicker.git --variable PHOTO_LIBRARY_USAGE_DESCRIPTION="your usage message"

cordova plugin add https://github.com/Telerik-Verified-Plugins/ImagePicker.git --variable PHOTO_LIBRARY_USAGE_DESCRIPTION="your usage message"
cordova plugin add https://github.com/VerianMobile/ImagePicker.git --variable PHOTO_LIBRARY_USAGE_DESCRIPTION="your usage message"


## Using the plugin
Expand Down
26 changes: 14 additions & 12 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

<header-file src="src/ios/GMImagePicker/FeHourGlass.h" />
<source-file src="src/ios/GMImagePicker/FeHourGlass.m" />

<header-file src="src/ios/GMImagePicker/UIImage+fixOrientation.h" />
<source-file src="src/ios/GMImagePicker/UIImage+fixOrientation.m" />

Expand Down Expand Up @@ -100,14 +100,14 @@
<param name="android-package" value="com.synconset.ImagePicker"/>
</feature>
</config-file>

<config-file target="AndroidManifest.xml" parent="/manifest/application">
<activity android:label="@string/multi_app_name" android:name="com.synconset.MultiImageChooserActivity" android:theme="@style/Theme.AppCompat.Light">
</activity>
</config-file>

<config-file target="AndroidManifest.xml" parent="/manifest">
<config-file target="AndroidManifest.xml" parent="/*">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
</config-file>

<preference name="ANDROID_SUPPORT_V7_VERSION" default="27.+"/>
Expand Down Expand Up @@ -139,8 +139,10 @@
<resource-file src="src/android/Library/res/layout/actionbar_done_button.xml" target="res/layout/actionbar_done_button.xml"/>
<resource-file src="src/android/Library/res/layout/multiselectorgrid.xml" target="res/layout/multiselectorgrid.xml"/>
<resource-file src="src/android/Library/res/values/multiimagechooser_strings_en.xml" target="res/values/multiimagechooser_strings_en.xml"/>
<resource-file src="src/android/Library/res/values/themes.xml" target="res/values/themes.xml"/>

<config-file target="res/values/themes.xml" parent="/resources">
<style name="MyTheme" parent="android:Theme.Holo.Light">
</style>
</config-file>
<resource-file src="src/android/Library/res/values-de/multiimagechooser_strings_de.xml" target="res/values-de/multiimagechooser_strings_de.xml"/>
<resource-file src="src/android/Library/res/values-es/multiimagechooser_strings_es.xml" target="res/values-es/multiimagechooser_strings_es.xml"/>
<resource-file src="src/android/Library/res/values-fr/multiimagechooser_strings_fr.xml" target="res/values-fr/multiimagechooser_strings_fr.xml"/>
Expand All @@ -158,19 +160,19 @@
<!-- browser -->
<platform name="browser">
<config-file parent="/*" target="config.xml">
<feature name="ImagePicker">
<param name="browser-package" value="ImagePicker"/>
</feature>
</config-file>
<feature name="ImagePicker">
<param name="browser-package" value="ImagePicker"/>
</feature>
</config-file>

<!-- Required for browserify: we always link module below as there is conditional reference
to this module from requestFileSystem and resolveLocalFileSystemURI modules. -->
<js-module src="www/browser/isChrome.js" name="isChrome">
<runs />
</js-module>

<js-module src="src/browser/ImagePicker.js" name="ImagePickerProxy">
<runs/>
</js-module>
<js-module src="src/browser/ImagePicker.js" name="ImagePickerProxy">
<runs/>
</js-module>
</platform>
</plugin>
4 changes: 2 additions & 2 deletions src/android/Library/src/MultiImageChooserActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@
import android.os.AsyncTask;
import android.os.Bundle;
import android.provider.MediaStore;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.ActionBar;
import android.util.Base64;
import android.util.SparseBooleanArray;
import android.view.Display;
Expand Down
18 changes: 13 additions & 5 deletions src/android/com/synconset/ImagePicker/ImagePicker.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;

public class ImagePicker extends CordovaPlugin {

Expand All @@ -32,6 +32,7 @@ public class ImagePicker extends CordovaPlugin {
private static final int PERMISSION_REQUEST_CODE = 100;

private CallbackContext callbackContext;


public boolean execute(String action, final JSONArray args, final CallbackContext callbackContext) throws JSONException {
this.callbackContext = callbackContext;
Expand Down Expand Up @@ -104,16 +105,23 @@ public boolean execute(String action, final JSONArray args, final CallbackContex

@SuppressLint("InlinedApi")
private boolean hasReadPermission() {
return Build.VERSION.SDK_INT < 23 ||
PackageManager.PERMISSION_GRANTED == ContextCompat.checkSelfPermission(this.cordova.getActivity(), Manifest.permission.READ_EXTERNAL_STORAGE);
String readImagePermission = Manifest.permission.READ_EXTERNAL_STORAGE;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
readImagePermission = Manifest.permission.READ_MEDIA_IMAGES;
}
return PackageManager.PERMISSION_GRANTED == ContextCompat.checkSelfPermission(this.cordova.getActivity(), readImagePermission);
}

@SuppressLint("InlinedApi")
private void requestReadPermission() {
String readImagePermission = Manifest.permission.READ_EXTERNAL_STORAGE;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
readImagePermission = Manifest.permission.READ_MEDIA_IMAGES;
}
if (!hasReadPermission()) {
ActivityCompat.requestPermissions(
this.cordova.getActivity(),
new String[] {Manifest.permission.READ_EXTERNAL_STORAGE},
new String[] { readImagePermission },
PERMISSION_REQUEST_CODE);
}
// This method executes async and we seem to have no known way to receive the result
Expand Down
1 change: 1 addition & 0 deletions src/ios/SOSPicker.m
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ - (void)launchGMImagePicker:(bool)allow_video title:(NSString *)title message:(N
UIPopoverPresentationController *popPC = picker.popoverPresentationController;
popPC.permittedArrowDirections = UIPopoverArrowDirectionAny;
popPC.sourceView = picker.view;
popPC.sourceRect = CGRectMake(0, 0, 0, 0);
//popPC.sourceRect = nil;
}

Expand Down