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

Master non native #756

Open
wants to merge 55 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
239190c
Fixed crash in UCrop.getOutputCropAspectRatio(data)
p1nkydev Mar 25, 2019
336127e
branch init
p1nkydev Mar 25, 2019
3a154ba
branch init
p1nkydev Mar 25, 2019
7cfef60
Merge branch 'feature/non_native' into develop-non-native
p1nkydev Mar 27, 2019
c39dcd4
Merge pull request #498 from Yalantis/bugfix/aspect_ratio_crash
ukevgen Apr 1, 2019
0f559e7
Merge branch 'feature/redesign' into develop-non-native
p1nkydev Apr 2, 2019
91ee731
Dependencies versions update
p1nkydev Apr 2, 2019
50ee19f
Merge pull request #506 from Yalantis/feature/redesign_non_native
ukevgen Apr 2, 2019
5f8f590
Merge pull request #508 from Yalantis/bugfix/sample_max_size_crash
ukevgen Apr 4, 2019
c1b6788
update readme and app version 2.2.3 with version code 24
Apr 4, 2019
6ed883e
gradle properties sync library version
Apr 4, 2019
765d7ac
gradle properties add non-native part
Apr 4, 2019
830d924
Merge pull request #510 from Yalantis/develop-non-native
Julia-Ts Apr 5, 2019
3fa0481
Merge branch 'feature/non_native' into feature/merge_non_native_updat…
OleksandNekrasov Sep 16, 2019
df14c58
Merge pull request #568 from Yalantis/feature/merge_non_native_update…
ukevgen Sep 16, 2019
901f480
Merge pull request #612 from Yalantis/fix/active_color_widget_issue_6…
Mar 18, 2020
b624c61
Changed AppCompatActivity to Activity for UCrop.start.
p1nkydev Mar 18, 2020
9c49279
Improve layout
hearsilent Mar 19, 2020
ba16db9
Merge pull request #633 from hearsilent/feature/non_native_improve_la…
Mar 19, 2020
aeffca7
Merge remote-tracking branch 'origin/master-non-native' into feature/…
Apr 28, 2020
684dd33
up version to 2.2.5
Apr 28, 2020
411a11f
Merge pull request #644 from Yalantis/feature/non_native
ukevgen Apr 29, 2020
6b2336e
Fixed cropped image size.
Aug 20, 2020
281c8e6
Merge pull request #693 from zalesskyi/fix/uCrop_non_native_result_size
warko-san Aug 20, 2020
eaa73c7
Fix for problems with input and output File Uri with "content" schema.
fabio-blanco Jan 17, 2021
aeed753
Typo fix on sample app button
fabio-blanco Jan 17, 2021
a4c89a1
Added ability to set custom OkHttpClient for image downloading
DeMoss15 May 20, 2021
fd919ea
added documentation for UCropHttpClientStore methods
DeMoss15 May 20, 2021
22b24ba
NullPointerException protection on weak reference of context get on c…
fabio-blanco May 20, 2021
fd65166
added UCropInitializer,
DeMoss15 May 21, 2021
eb2d32f
Refactorings on BitmapCropTask for improving readability protections …
fabio-blanco May 21, 2021
32e0fcd
Merge pull request #758 from Yalantis/fix/non_native_ssl_handshake_ex…
severianremi May 24, 2021
586493a
Added an IllegalArgumentException in the copyFile method to inform th…
fabio-blanco May 24, 2021
cd17761
Merge branch 'master-non-native' into merge_non_native_android-10_saf…
fabio-blanco May 24, 2021
0ff3e6a
Merge pull request #732 from fabio-blanco/fix/non_native_android-10_s…
DeMoss15 May 25, 2021
70546c1
Updated dependencies
DeMoss15 May 25, 2021
64c8f5b
Merge pull request #762 from Yalantis/improve/update_sample_app
severianremi May 25, 2021
b89a37c
Migrate jcenter usage to mavenCentral
dmytro1morozov Jan 21, 2022
1d6f5f9
add zh locale strings
TelephoneTan Feb 12, 2021
0541494
Add ru locale
alesharik Sep 29, 2020
f3d915e
nl locale
rielcs Sep 10, 2020
9443f87
Add Farsi (Persian) string translations
momvart Sep 5, 2020
2e1b5b5
update german localization
hdruse Jun 2, 2020
b66e256
feat(i18n): update Simplified and traditional Chinese language
snowyu Jun 4, 2019
5cedf34
fix portuguese language file
luisvasquez Jul 17, 2020
047ea79
added google translated Thai, Indonesian and Turkish languages
luisvasquez Jul 17, 2020
35d4ca6
fix aspect ratio bugs
Nov 10, 2020
5b1d592
Improve readme
Drjacky Nov 18, 2020
38d909d
Added functionality to enable/disable gestures in GestureCropImageView
Jan 7, 2020
2f52086
Merge pull request #812 from Yalantis/improve/non_native/2.2.8-prs_in…
severianremi Jan 27, 2022
7ee5fe9
Update compileSdk and targetSdk versions up to 31
dmytro1morozov Jan 21, 2022
2149b63
Fix launch of sample app on Android 12
denylok Jan 21, 2022
e957285
Fix Vector drawable issue on Android 5.0
dmytro1morozov Jan 20, 2022
161c792
Release 2.2.8
dmytro1morozov Jan 31, 2022
5b190f0
Merge pull request #815 from Yalantis/develop-non-native
severianremi Jan 31, 2022
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
63 changes: 40 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@

<a href="https://play.google.com/store/apps/details?id=com.yalantis.ucrop.sample&utm_source=global_co&utm_medium=prtnr&utm_content=Mar2515&utm_campaign=PartBadge&pcampaignid=MKT-AC-global-none-all-co-pr-py-PartBadges-Oct1515-1"><img alt="Get it on Google Play" src="https://play.google.com/intl/en_us/badges/images/generic/en_badge_web_generic.png" width="185" height="70"/></a>

1. Include the library as local library project.
1. Include the library as a local library project.

```
allprojects {
repositories {
jcenter()
...
maven { url "https://jitpack.io" }
}
}
```

``` compile 'com.github.yalantis:ucrop:2.2.2' ``` - lightweight general solution
``` compile 'com.github.yalantis:ucrop:2.2.2-native' ``` - get power of the native code to preserve image quality (+ about 1.5 MB to an apk size)
``` implementation 'com.github.yalantis:ucrop:2.2.3' ``` - lightweight general solution

``` implementation 'com.github.yalantis:ucrop:2.2.3-native' ``` - get power of the native code to preserve image quality (+ about 1.5 MB to an apk size)

2. Add UCropActivity into your AndroidManifest.xml

```
Expand Down Expand Up @@ -73,29 +73,46 @@ If you want to let your users choose crop ratio dynamically, just do not call `w

uCrop builder class has method `withOptions(UCrop.Options options)` which extends library configurations.

Currently you can change:
Currently, you can change:

* image compression format (e.g. PNG, JPEG, WEBP), compression
* image compression quality [0 - 100]. PNG which is lossless, will ignore the quality setting.
* whether all gestures are enabled simultaneously
* maximum size for Bitmap that is decoded from source Uri and used within crop view. If you want to override default behaviour.
* maximum size for Bitmap that is decoded from source Uri and used within crop view. If you want to override the default behaviour.
* toggle whether to show crop frame/guidelines
* setup color/width/count of crop frame/rows/columns
* choose whether you want rectangle or oval crop area
* choose whether you want rectangle or oval(`options.setCircleDimmedLayer(true)`) crop area
* the UI colors (Toolbar, StatusBar, active widget state)
* and more...


Since version 2.2.7 in case if you need to change transport protocol, setup timeout etc. You may set your `OkHttpClient` next way:

```java
new UCropInitializer().setOkHttpClient(client);
```

# Compatibility

* Library - Android ICS 4.0+ (API 14) (Android GINGERBREAD 2.3+ (API 10) for versions <= 1.3.2)
* Sample - Android ICS 4.0+ (API 14)
* CPU - armeabi armeabi-v7a x86 x86_64 arm64-v8a (for versions >= 2.1.2)

# Changelog
### Version: 2.2.2

* uCrop fragment added
* bugfix
### Version: 2.2.8

* Merged pending pull requests with improvements and bugfixes
* Update compileSdk and targetSdk versions up to 31
* Add localizations
* Fixed [#609](https://github.com/Yalantis/uCrop/issues/609)
* Fixed [#794](https://github.com/Yalantis/uCrop/issues/794)

### Version: 2.2.3

* Several fixes including [#445](https://github.com/Yalantis/uCrop/issues/445), [#465](https://github.com/Yalantis/uCrop/issues/465) and more!
* Material design support
* uCrop fragment as child fragment
* Added the Italian language

### Version: 2.2.2

Expand All @@ -114,7 +131,7 @@ Currently you can change:
### Version: 2.1

* Fixes issue with EXIF data (images taken on front camera with Samsung devices mostly) [#130](https://github.com/Yalantis/uCrop/issues/130) [#111](https://github.com/Yalantis/uCrop/issues/111)
* Added API to set custom set of aspect ratio options for user. [#131](https://github.com/Yalantis/uCrop/issues/131)
* Added API to set custom set of aspect ratio options for the user. [#131](https://github.com/Yalantis/uCrop/issues/131)
* Added API to set all configs via UCrop.Options class. [#126](https://github.com/Yalantis/uCrop/issues/126)
* Added ABI x86_64 support. [#105](https://github.com/Yalantis/uCrop/issues/105)

Expand All @@ -123,7 +140,7 @@ Currently you can change:
* Native image crop (able to crop high-resolution images, e.g. 16MP & 32MP images on Nexus 5X).
* WebP compression format is not supported at the moment (choose JPEG or PNG).
* Now library copies EXIF data to cropped image (size and orientation are updated).

### Version: 1.5

* Introduced "Freestyle" crop (you can resize crop rectangle by dragging it corners) [#32](https://github.com/Yalantis/uCrop/issues/32)
Expand All @@ -132,21 +149,21 @@ Currently you can change:

### Version: 1.4

* Introduced http(s) Uri support!
* Image is cropped in background thread.
* Introduced HTTP(s) Uri support!
* Image is cropped in a background thread.
* Showing loader while Bitmap is processed (both loading and cropping).
* Several bug fixes.
* Couple new things to configure.
* Updated minSdkVersion to Android ICS 4.0 (no reason to support couple percents of old phones).

### Version: 1.3

* Image is loaded in background thread. Better error-handling for image decoding.
* Image is loaded in a background thread. Better error-handling for image decoding.
* Improved EXIF data support (rotation and mirror).
* Small UI updates.
* Couple new things to configure.
* Sample updated with possibility to choose custom aspect ratio.

* Sample updated with the possibility to choose custom aspect ratio.

### Version: 1.2

Expand All @@ -162,7 +179,7 @@ Currently you can change:

### Let us know!

We’d be really happy if you sent us links to your projects where you use our component. Just send an email to [email protected] And do let us know if you have any questions or suggestion regarding the library.
We’d be really happy if you sent us links to your projects where you use our component. Just send an email to [email protected] And do let us know if you have any questions or suggestion regarding the library.

#### Apps using uCrop

Expand Down
10 changes: 5 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
buildscript {
ext {
androidx_appcompat_version = "1.1.0"
androidx_appcompat_version = "1.3.0"
androidx_core_version = "1.1.0"
androidx_exifinterface_version = "1.1.0-beta01"
androidx_transition_version = "1.2.0-rc01"
androidx_exifinterface_version = "1.3.2"
androidx_transition_version = "1.4.1"
constraintlayout_version = "1.1.3"
}

repositories {
jcenter()
mavenCentral()
maven {
url 'https://maven.google.com/'
name 'Google'
Expand All @@ -28,7 +28,7 @@ allprojects {
group = GROUP

repositories {
jcenter()
mavenCentral()
maven {
url 'https://maven.google.com/'
name 'Google'
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

VERSION_NAME=2.2.2-non-native
VERSION_CODE=24
VERSION_NAME=2.2.8-native
VERSION_CODE=26
GROUP=com.yalantis

POM_DESCRIPTION=Android Library for cropping images
Expand Down
7 changes: 4 additions & 3 deletions sample/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 29
buildToolsVersion '28.0.3'
compileSdkVersion 31
buildToolsVersion '30.0.3'
defaultConfig {
applicationId "com.yalantis.ucrop.sample"
minSdkVersion 14
targetSdkVersion 29
targetSdkVersion 31
versionCode 13
versionName "1.2.4"
}
Expand Down Expand Up @@ -38,5 +38,6 @@ dependencies {
implementation "androidx.appcompat:appcompat:1.1.0"
implementation "androidx.core:core:1.1.0"
implementation "androidx.constraintlayout:constraintlayout:1.1.3"
implementation "com.squareup.okhttp3:okhttp:3.12.13"
implementation project(':ucrop')
}
4 changes: 3 additions & 1 deletion sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<uses-permission android:name="android.permission.INTERNET" />

<application
android:name=".SampleApp"
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
Expand All @@ -23,7 +24,8 @@

<activity
android:name=".SampleActivity"
android:screenOrientation="portrait">
android:screenOrientation="portrait"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
62 changes: 51 additions & 11 deletions sample/src/main/java/com/yalantis/ucrop/sample/ResultActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,30 @@
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.widget.Toolbar;
import androidx.core.app.ActivityCompat;
import androidx.core.app.NotificationCompat;
import androidx.core.content.FileProvider;

import com.yalantis.ucrop.util.BitmapLoadUtils;
import com.yalantis.ucrop.view.UCropView;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.channels.FileChannel;
import java.util.Calendar;
import java.util.List;

import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.widget.Toolbar;
import androidx.core.app.ActivityCompat;
import androidx.core.app.NotificationCompat;
import androidx.core.content.FileProvider;

import static android.content.Intent.FLAG_GRANT_READ_URI_PERMISSION;
import static android.content.Intent.FLAG_GRANT_WRITE_URI_PERMISSION;

Expand All @@ -59,27 +65,58 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_result);
Uri uri = getIntent().getData();
int width = 0;
int height = 0;
if (uri != null) {
try {
UCropView uCropView = findViewById(R.id.ucrop);
uCropView.getCropImageView().setImageUri(uri, null);
uCropView.getOverlayView().setShowCropFrame(false);
uCropView.getOverlayView().setShowCropGrid(false);
uCropView.getOverlayView().setDimmedColor(Color.TRANSPARENT);

if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP && "content".equals(uri.getScheme())) {
TextView textViewExifWarning = findViewById(R.id.text_view_content_warning);
textViewExifWarning.setVisibility(View.VISIBLE);
}
} catch (Exception e) {
Log.e(TAG, "setImageUri", e);
Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show();
}

final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;

if ("content".equals(uri.getScheme())) {
InputStream is = null;
try {
is = getContentResolver().openInputStream(uri);
BitmapFactory.decodeStream(is, null, options);
} catch (FileNotFoundException e) {
Log.d(TAG, e.getMessage(), e);
} finally {
if (is != null) {
try {
is.close();
} catch (IOException e) {
Log.e(TAG, e.getMessage(), e);
}
}
}
} else {
File file = new File(getIntent().getData().getPath());
BitmapFactory.decodeFile(file.getAbsolutePath(), options);
}

width = options.outWidth;
height = options.outHeight;
}
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(new File(getIntent().getData().getPath()).getAbsolutePath(), options);

setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
final ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setTitle(getString(R.string.format_crop_result_d_d, options.outWidth, options.outHeight));
actionBar.setTitle(getString(R.string.format_crop_result_d_d, width, height));
}
}

Expand Down Expand Up @@ -131,6 +168,9 @@ private void saveCroppedImage() {
Toast.makeText(ResultActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
Log.e(TAG, imageUri.toString(), e);
}
} else if (BitmapLoadUtils.hasContentScheme(imageUri)){
Toast.makeText(ResultActivity.this, getString(R.string.toast_already_saved), Toast.LENGTH_SHORT).show();
finish();
} else {
Toast.makeText(ResultActivity.this, getString(R.string.toast_unexpected_error), Toast.LENGTH_SHORT).show();
}
Expand Down
Loading