Commit a7c1dc96 authored by Sébastiaan Versteeg's avatar Sébastiaan Versteeg

Merge branch 'cropper-android' into 'master'

Replace image picker lib

See merge request !291
parents 2ee23829 6ced4dc2
......@@ -79,7 +79,7 @@ dependencies {
implementation project(':@react-native-community_status-bar')
implementation project(':@react-native-community_async-storage')
implementation project(':react-native-device-info')
implementation project(':react-native-image-picker')
implementation project(':react-native-image-crop-picker')
implementation project(':react-native-screens')
implementation project(':react-native-gesture-handler')
implementation project(':react-native-sentry')
......
......@@ -63,15 +63,5 @@
<meta-data
android:name="android.max_aspect"
android:value="2.1" />
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}.provider"
android:grantUriPermissions="true"
android:exported="false">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/filepaths" />
</provider>
</application>
</manifest>
......@@ -8,7 +8,7 @@ import com.reactnativecommunity.asyncstorage.AsyncStoragePackage;
import com.learnium.RNDeviceInfo.RNDeviceInfo;
import com.swmansion.rnscreens.RNScreensPackage;
import com.swmansion.gesturehandler.react.RNGestureHandlerPackage;
import com.imagepicker.ImagePickerPackage;
import com.reactnative.ivpusic.imagepicker.PickerPackage;
import cl.json.ShareApplication;
import cl.json.RNSharePackage;
......@@ -45,7 +45,7 @@ public class MainApplication extends Application implements ShareApplication, Re
new RNDeviceInfo(),
new RNScreensPackage(),
new RNGestureHandlerPackage(),
new ImagePickerPackage(),
new PickerPackage(),
new RNSharePackage(),
new RNSentryPackage(),
new SnackbarPackage(),
......
......@@ -22,6 +22,7 @@ allprojects {
url "$rootDir/../node_modules/react-native/android"
}
mavenLocal()
maven { url "https://jitpack.io" }
google()
mavenCentral()
jcenter()
......
......@@ -9,8 +9,8 @@ include ':react-native-screens'
project(':react-native-screens').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-screens/android')
include ':react-native-gesture-handler'
project(':react-native-gesture-handler').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-gesture-handler/android')
include ':react-native-image-picker'
project(':react-native-image-picker').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-image-picker/android')
include ':react-native-image-crop-picker'
project(':react-native-image-crop-picker').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-image-crop-picker/android')
include ':react-native-share'
project(':react-native-share').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-share/android')
include ':react-native-sentry'
......
import ImagePicker from 'react-native-image-picker';
import ImagePicker from 'react-native-image-crop-picker';
import {
call, put, select, takeEvery,
} from 'redux-saga/effects';
import { Alert, Platform } from 'react-native';
import { Alert } from 'react-native';
import Snackbar from 'react-native-snackbar';
import i18next from '../utils/i18n';
......@@ -10,18 +10,10 @@ import { apiRequest } from '../utils/url';
import * as profileActions from '../actions/profile';
import { tokenSelector } from '../selectors/session';
import reportError from '../utils/errorReporting';
import * as sessionActions from '../actions/session';
const t = i18next.getFixedT(undefined, 'sagas/profile');
const openImageLibrary = options => new Promise((resolve, reject) => {
ImagePicker.showImagePicker(options, (response) => {
if (response.error || response.didCancel) {
reject(response);
}
resolve(response);
});
});
function* profile(action) {
const { member } = action.payload;
const token = yield select(tokenSelector);
......@@ -49,22 +41,22 @@ function* profile(action) {
function* updateAvatar() {
const options = {
title: t('Change profile picture'),
storageOptions: {
skipBackup: true,
path: 'images',
},
width: 500,
height: 500,
cropping: true,
mediaType: 'photo',
};
try {
const photo = yield call(openImageLibrary, options);
const photo = yield call([ImagePicker, 'openPicker'], options);
const fileName = photo.path.split('/').pop();
const formData = new FormData();
formData.append('photo', {
name: photo.fileName,
type: photo.type,
uri:
Platform.OS === 'android' ? photo.uri : photo.uri.replace('file://', ''),
name: fileName,
type: photo.mime,
uri: photo.path,
});
const token = yield select(tokenSelector);
......@@ -73,7 +65,7 @@ function* updateAvatar() {
method: 'PATCH',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
'Content-Type': 'multipart/form-data',
Authorization: `Token ${token}`,
},
body: formData,
......@@ -84,6 +76,7 @@ function* updateAvatar() {
const profileData = yield call(apiRequest, 'members/me', data);
yield call([Snackbar, 'dismiss']);
yield put(profileActions.success(profileData));
yield put(sessionActions.fetchUserInfo());
} catch (error) {
yield call([Snackbar, 'dismiss']);
yield call(reportError, error);
......
......@@ -9,6 +9,7 @@ const AvatarModal = props => (
visible={props.visible}
transparent
animationType="fade"
onRequestClose={props.close}
>
<View
style={styles.background}
......
......@@ -146,6 +146,7 @@ class ProfileScreen extends Component {
>
<View style={styles.touchableHeader} />
</TouchableHighlight>
<View style={styles.headerIconPressBlocker} />
<IconButton
onPress={this.props.goBack}
name="arrow-back"
......
......@@ -122,6 +122,14 @@ const styles = StyleSheet.create({
top: 0,
bottom: 0,
},
headerIconPressBlocker: {
position: 'absolute',
left: 0,
top: 0,
width: 64,
height: (HEADER_MIN_HEIGHT - 24) + STATUSBAR_HEIGHT,
backgroundColor: Colors.transparent,
},
overlayGradient: {
position: 'absolute',
top: '50%',
......
......@@ -41,7 +41,9 @@
3238F61D229F16FE00BEB7F8 /* libRNDeviceInfo.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3238F61A229F16F400BEB7F8 /* libRNDeviceInfo.a */; };
32472E7522A00BB7002A0BC5 /* libRNCAsyncStorage.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 32472E6822A00BB1002A0BC5 /* libRNCAsyncStorage.a */; };
32472E7E22A00FBC002A0BC5 /* libRNCStatusBar.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 32472E7D22A00FB4002A0BC5 /* libRNCStatusBar.a */; };
3269FBC722B2B8D100969EDE /* libRNImagePicker.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3269FBBF22B2B8C800969EDE /* libRNImagePicker.a */; };
3269FC3822B39E1A00969EDE /* libimageCropPicker.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3269FC3722B39E0F00969EDE /* libimageCropPicker.a */; };
3269FC3A22B39E2D00969EDE /* RSKImageCropper.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3269FC3922B39E2D00969EDE /* RSKImageCropper.framework */; };
3269FC3C22B39E3A00969EDE /* QBImagePicker.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3269FC3B22B39E3A00969EDE /* QBImagePicker.framework */; };
327DC4A2229EB48000DE29E9 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 327DC4A1229EB48000DE29E9 /* GoogleService-Info.plist */; };
327DC54B229EB8E100DE29E9 /* libBVLinearGradient.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 327DC537229EB6C300DE29E9 /* libBVLinearGradient.a */; };
327DC54C229EB8E100DE29E9 /* libRNScreens.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 327DC527229EB68D00DE29E9 /* libRNScreens.a */; };
......@@ -227,12 +229,12 @@
remoteGlobalIDString = 134814201AA4EA6300B7C361;
remoteInfo = RNCStatusBar;
};
3269FBBE22B2B8C800969EDE /* PBXContainerItemProxy */ = {
3269FC3622B39E0F00969EDE /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 3269FB8D22B2B8C800969EDE /* RNImagePicker.xcodeproj */;
containerPortal = 3269FC3022B39E0F00969EDE /* imageCropPicker.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 014A3B5C1C6CF33500B6D375;
remoteInfo = RNImagePicker;
remoteGlobalIDString = 3400A8081CEB54A6008A0BC7;
remoteInfo = imageCropPicker;
};
327DC48C229EB42900DE29E9 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
......@@ -493,7 +495,9 @@
3238F614229F16F300BEB7F8 /* RNDeviceInfo.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RNDeviceInfo.xcodeproj; path = "../node_modules/react-native-device-info/ios/RNDeviceInfo.xcodeproj"; sourceTree = "<group>"; };
32472E3B22A00BB1002A0BC5 /* RNCAsyncStorage.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RNCAsyncStorage.xcodeproj; path = "../node_modules/@react-native-community/async-storage/ios/RNCAsyncStorage.xcodeproj"; sourceTree = "<group>"; };
32472E7822A00FB4002A0BC5 /* RNCStatusBar.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RNCStatusBar.xcodeproj; path = "../node_modules/@react-native-community/status-bar/ios/RNCStatusBar.xcodeproj"; sourceTree = "<group>"; };
3269FB8D22B2B8C800969EDE /* RNImagePicker.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RNImagePicker.xcodeproj; path = "../node_modules/react-native-image-picker/ios/RNImagePicker.xcodeproj"; sourceTree = "<group>"; };
3269FC3022B39E0F00969EDE /* imageCropPicker.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = imageCropPicker.xcodeproj; path = "../node_modules/react-native-image-crop-picker/ios/imageCropPicker.xcodeproj"; sourceTree = "<group>"; };
3269FC3922B39E2D00969EDE /* RSKImageCropper.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = RSKImageCropper.framework; sourceTree = BUILT_PRODUCTS_DIR; };
3269FC3B22B39E3A00969EDE /* QBImagePicker.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = QBImagePicker.framework; sourceTree = BUILT_PRODUCTS_DIR; };
327DC4A1229EB48000DE29E9 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
327DC4A3229EB53A00DE29E9 /* ThaliApp.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; name = ThaliApp.entitlements; path = ThaliApp/ThaliApp.entitlements; sourceTree = "<group>"; };
327DC4B2229EB5A700DE29E9 /* RNSentry.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RNSentry.xcodeproj; path = "../node_modules/react-native-sentry/ios/RNSentry.xcodeproj"; sourceTree = "<group>"; };
......@@ -544,7 +548,9 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
3269FBC722B2B8D100969EDE /* libRNImagePicker.a in Frameworks */,
3269FC3C22B39E3A00969EDE /* QBImagePicker.framework in Frameworks */,
3269FC3A22B39E2D00969EDE /* RSKImageCropper.framework in Frameworks */,
3269FC3822B39E1A00969EDE /* libimageCropPicker.a in Frameworks */,
32472E7E22A00FBC002A0BC5 /* libRNCStatusBar.a in Frameworks */,
32472E7522A00BB7002A0BC5 /* libRNCAsyncStorage.a in Frameworks */,
3238F61D229F16FE00BEB7F8 /* libRNDeviceInfo.a in Frameworks */,
......@@ -735,6 +741,8 @@
2D16E6871FA4F8E400B85C8A /* Frameworks */ = {
isa = PBXGroup;
children = (
3269FC3B22B39E3A00969EDE /* QBImagePicker.framework */,
3269FC3922B39E2D00969EDE /* RSKImageCropper.framework */,
327DC551229EB8EF00DE29E9 /* AssetsLibrary.framework */,
ED297162215061F000B7C4FE /* JavaScriptCore.framework */,
ED2971642150620600B7C4FE /* JavaScriptCore.framework */,
......@@ -771,10 +779,10 @@
name = Products;
sourceTree = "<group>";
};
3269FB8E22B2B8C800969EDE /* Products */ = {
3269FC3122B39E0F00969EDE /* Products */ = {
isa = PBXGroup;
children = (
3269FBBF22B2B8C800969EDE /* libRNImagePicker.a */,
3269FC3722B39E0F00969EDE /* libimageCropPicker.a */,
);
name = Products;
sourceTree = "<group>";
......@@ -889,7 +897,7 @@
832341AE1AAA6A7D00B99B32 /* Libraries */ = {
isa = PBXGroup;
children = (
3269FB8D22B2B8C800969EDE /* RNImagePicker.xcodeproj */,
3269FC3022B39E0F00969EDE /* imageCropPicker.xcodeproj */,
32472E7822A00FB4002A0BC5 /* RNCStatusBar.xcodeproj */,
32472E3B22A00BB1002A0BC5 /* RNCAsyncStorage.xcodeproj */,
3238F614229F16F300BEB7F8 /* RNDeviceInfo.xcodeproj */,
......@@ -1084,6 +1092,10 @@
ProductGroup = 327DC532229EB6C300DE29E9 /* Products */;
ProjectRef = 327DC531229EB6C300DE29E9 /* BVLinearGradient.xcodeproj */;
},
{
ProductGroup = 3269FC3122B39E0F00969EDE /* Products */;
ProjectRef = 3269FC3022B39E0F00969EDE /* imageCropPicker.xcodeproj */;
},
{
ProductGroup = 00C302A81ABCB8CE00DB3ED1 /* Products */;
ProjectRef = 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */;
......@@ -1148,10 +1160,6 @@
ProductGroup = 327DC543229EB76A00DE29E9 /* Products */;
ProjectRef = 327DC542229EB76A00DE29E9 /* RNGestureHandler.xcodeproj */;
},
{
ProductGroup = 3269FB8E22B2B8C800969EDE /* Products */;
ProjectRef = 3269FB8D22B2B8C800969EDE /* RNImagePicker.xcodeproj */;
},
{
ProductGroup = 327DC523229EB68D00DE29E9 /* Products */;
ProjectRef = 327DC522229EB68D00DE29E9 /* RNScreens.xcodeproj */;
......@@ -1324,11 +1332,11 @@
remoteRef = 32472E7C22A00FB4002A0BC5 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
3269FBBF22B2B8C800969EDE /* libRNImagePicker.a */ = {
3269FC3722B39E0F00969EDE /* libimageCropPicker.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libRNImagePicker.a;
remoteRef = 3269FBBE22B2B8C800969EDE /* PBXContainerItemProxy */;
path = libimageCropPicker.a;
remoteRef = 3269FC3622B39E0F00969EDE /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
327DC48D229EB42900DE29E9 /* libjsi.a */ = {
......
......@@ -7220,10 +7220,10 @@ react-native-git-upgrade@0.2.7:
shelljs "^0.7.5"
yeoman-environment "1.5.3"
react-native-image-picker@0.28.1:
version "0.28.1"
resolved "https://registry.yarnpkg.com/react-native-image-picker/-/react-native-image-picker-0.28.1.tgz#1127460522e0c9741fc62f3d040271d298fb6a6e"
integrity sha512-CW2dm+cjsdW2fjBW2WD/cSufNG0x0UpljwGHrjSzyB0TckoW+tjYv44UWtckCWxr1JtCg+QrYDO/MzlRyFcjwQ==
react-native-image-crop-picker@^0.24.1:
version "0.24.1"
resolved "https://registry.yarnpkg.com/react-native-image-crop-picker/-/react-native-image-crop-picker-0.24.1.tgz#4408e2bb20e3c082c0191e0acf0c8c7a1e9804ea"
integrity sha512-M+6iFhDXPDtf++X+fvb5mKkLw2978SbyPVVQHigktgKONxtTZtBiOOtYfBUIkPaSetP20P9q4iwOu+iTaZ/R+w==
react-native-linear-gradient@2.5.4:
version "2.5.4"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment