mirror of
https://github.com/status-im/react-native-image-crop-picker.git
synced 2025-02-20 17:38:16 +00:00
update android support library to androidx (#1048)
* Update PickerModule.java * Update RealPathUtil.java * Update AndroidManifest.xml
This commit is contained in:
parent
ef4635cc94
commit
8aec9a4e53
@ -6,7 +6,7 @@
|
||||
<application>
|
||||
|
||||
<provider
|
||||
android:name="android.support.v4.content.FileProvider"
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
android:authorities="${applicationId}.provider"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true">
|
||||
|
@ -3,6 +3,7 @@ package com.reactnative.ivpusic.imagepicker;
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.content.ClipData;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Bitmap;
|
||||
@ -13,12 +14,11 @@ import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
import android.provider.MediaStore;
|
||||
import android.support.annotation.RequiresApi;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.support.v4.content.FileProvider;
|
||||
import android.util.Base64;
|
||||
import android.webkit.MimeTypeMap;
|
||||
import android.content.ContentResolver;
|
||||
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.FileProvider;
|
||||
|
||||
import com.facebook.react.bridge.ActivityEventListener;
|
||||
import com.facebook.react.bridge.Callback;
|
||||
@ -401,29 +401,30 @@ class PickerModule extends ReactContextBaseJavaModule implements ActivityEventLi
|
||||
}
|
||||
|
||||
private String getBase64StringFromFile(String absoluteFilePath) {
|
||||
try (
|
||||
InputStream inputStream = new FileInputStream(new File(absoluteFilePath));
|
||||
ByteArrayOutputStream output = new ByteArrayOutputStream()
|
||||
) {
|
||||
byte[] bytes;
|
||||
byte[] buffer = new byte[8192];
|
||||
int bytesRead;
|
||||
InputStream inputStream;
|
||||
|
||||
try {
|
||||
while ((bytesRead = inputStream.read(buffer)) != -1) {
|
||||
output.write(buffer, 0, bytesRead);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
bytes = output.toByteArray();
|
||||
return Base64.encodeToString(bytes, Base64.NO_WRAP);
|
||||
} catch (IOException e) {
|
||||
try {
|
||||
inputStream = new FileInputStream(new File(absoluteFilePath));
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
||||
byte[] bytes;
|
||||
byte[] buffer = new byte[8192];
|
||||
int bytesRead;
|
||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||
|
||||
try {
|
||||
while ((bytesRead = inputStream.read(buffer)) != -1) {
|
||||
output.write(buffer, 0, bytesRead);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
bytes = output.toByteArray();
|
||||
return Base64.encodeToString(bytes, Base64.NO_WRAP);
|
||||
}
|
||||
|
||||
private String getMimeType(String url) {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.reactnative.ivpusic.imagepicker;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.ContentUris;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
@ -15,6 +16,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
class RealPathUtil {
|
||||
@TargetApi(Build.VERSION_CODES.KITKAT)
|
||||
static String getRealPathFromURI(final Context context, final Uri uri) throws IOException {
|
||||
|
||||
final boolean isKitKat = Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT;
|
||||
@ -198,6 +200,7 @@ class RealPathUtil {
|
||||
return "com.google.android.apps.photos.content".equals(uri.getAuthority());
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.KITKAT)
|
||||
private static String getPathToNonPrimaryVolume(Context context, String tag) {
|
||||
File[] volumes = context.getExternalCacheDirs();
|
||||
if (volumes != null) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user