|
24 | 24 | }
|
25 | 25 | ```
|
26 | 26 |
|
27 |
| - ``` implementation 'com.github.yalantis:ucrop:2.2.9' ``` - lightweight general solution |
| 27 | + ``` implementation 'com.github.yalantis:ucrop:2.2.8' ``` - lightweight general solution |
28 | 28 |
|
29 |
| - ``` implementation 'com.github.yalantis:ucrop:2.2.9-native' ``` - get power of the native code to preserve image quality (+ about 1.5 MB to an apk size) |
| 29 | + ``` implementation 'com.github.yalantis:ucrop:2.2.8-native' ``` - get power of the native code to preserve image quality (+ about 1.5 MB to an apk size) |
30 | 30 |
|
31 | 31 | 2. Add UCropActivity into your AndroidManifest.xml
|
32 | 32 |
|
|
37 | 37 | android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>
|
38 | 38 | ```
|
39 | 39 |
|
40 |
| -3. Register a callback for the uCrop result. |
41 |
| -
|
42 |
| - ```java |
43 |
| - private ActivityResultLauncher<Intent> activityResultLauncher = |
44 |
| - registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> { |
45 |
| - if (result.getResultCode() == RESULT_OK) { |
46 |
| - final Uri resultUri = UCrop.getOutput(result.getData()); |
47 |
| - } else if (result.getResultCode() == UCrop.RESULT_ERROR) { |
48 |
| - final Throwable cropError = UCrop.getError(result.getData()); |
49 |
| - } |
50 |
| - }); |
51 |
| - ``` |
52 |
| -
|
53 |
| -4. Create the uCrop configuration using the builder pattern. |
| 40 | +3. The uCrop configuration is created using the builder pattern. |
54 | 41 |
|
55 | 42 | ```java
|
56 | 43 | UCrop.of(sourceUri, destinationUri)
|
57 | 44 | .withAspectRatio(16, 9)
|
58 | 45 | .withMaxResultSize(maxWidth, maxHeight)
|
59 |
| - .start(context, activityResultLauncher); |
| 46 | + .start(context); |
60 | 47 | ```
|
61 | 48 |
|
| 49 | +4. Override `onActivityResult` method and handle uCrop result. |
| 50 | + |
| 51 | + ```java |
| 52 | + @Override |
| 53 | + public void onActivityResult(int requestCode, int resultCode, Intent data) { |
| 54 | + if (resultCode == RESULT_OK && requestCode == UCrop.REQUEST_CROP) { |
| 55 | + final Uri resultUri = UCrop.getOutput(data); |
| 56 | + } else if (resultCode == UCrop.RESULT_ERROR) { |
| 57 | + final Throwable cropError = UCrop.getError(data); |
| 58 | + } |
| 59 | + } |
| 60 | + ``` |
| 61 | + |
62 | 62 | 5. You may want to add this to your PROGUARD config:
|
63 | 63 |
|
64 | 64 | ```
|
@@ -93,13 +93,6 @@ Currently, you can change:
|
93 | 93 |
|
94 | 94 | # Changelog
|
95 | 95 |
|
96 |
| -### Version: 2.2.9 |
97 |
| -
|
98 |
| -* Update compileSdk and targetSdk versions up to 33 |
99 |
| -* Fixed [#867](https://github.com/Yalantis/uCrop/issues/867) |
100 |
| -* Fixed [#873](https://github.com/Yalantis/uCrop/issues/873) |
101 |
| -* And other improvements |
102 |
| -
|
103 | 96 | ### Version: 2.2.8
|
104 | 97 |
|
105 | 98 | * Merged pending pull requests with improvements and bugfixes
|
|
0 commit comments