Skip to content

Commit

Permalink
Merge pull request Yalantis#510 from Yalantis/develop-non-native
Browse files Browse the repository at this point in the history
prepared for new "non-native" release: redesign + fixes
  • Loading branch information
Julia-Ts committed Apr 5, 2019
2 parents 3a154ba + 765d7ac commit 830d924
Show file tree
Hide file tree
Showing 74 changed files with 409 additions and 146 deletions.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
}
```

``` compile 'com.github.yalantis:ucrop:2.2.2' ``` - lightweight general solution
``` implementation 'com.github.yalantis:ucrop:2.2.3' ``` - 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-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 @@ -92,10 +92,12 @@ Currently you can change:
* CPU - armeabi armeabi-v7a x86 x86_64 arm64-v8a (for versions >= 2.1.2)

# Changelog
### Version: 2.2.2
### Version: 2.2.3

* uCrop fragment added
* bugfix
* 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 Italian language

### Version: 2.2.2

Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ buildscript {
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
classpath 'com.android.tools.build:gradle:3.3.2'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
ext {
support = '27.1.0'
support = '28.0.0'
constraints = '1.0.2'
}
}
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.0-native
VERSION_CODE=22
VERSION_NAME=2.2.3-non-native
VERSION_CODE=24
GROUP=com.yalantis

POM_DESCRIPTION=Android Library for cropping images
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
12 changes: 6 additions & 6 deletions sample/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.yalantis.ucrop.sample"
minSdkVersion 14
targetSdkVersion 27
versionCode 11
versionName "1.2.3"
targetSdkVersion 28
versionCode 12
versionName "1.2.4"
}
flavorDimensions "default"
buildTypes {
Expand Down Expand Up @@ -37,6 +37,6 @@ android {
dependencies {
implementation "com.android.support:appcompat-v7:$support"
implementation "com.android.support:support-compat:$support"
implementation "com.android.support.constraint:constraint-layout:$constraints"
implementation "com.android.support.constraint:constraint-layout:1.1.3"
implementation project(':ucrop')
}
79 changes: 39 additions & 40 deletions sample/src/main/java/com/yalantis/ucrop/sample/SampleActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,43 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis
}
}


private TextWatcher mAspectRatioTextWatcher = new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
mRadioGroupAspectRatio.clearCheck();
}

@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {

}

@Override
public void afterTextChanged(Editable s) {

}
};
private TextWatcher mMaxSizeTextWatcher = new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}

@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {

}

@Override
public void afterTextChanged(Editable s) {
if (s != null && !s.toString().trim().isEmpty()) {
if (Integer.valueOf(s.toString()) < UCrop.MIN_SIZE) {
Toast.makeText(SampleActivity.this, String.format(getString(R.string.format_max_cropped_image_size), UCrop.MIN_SIZE), Toast.LENGTH_SHORT).show();
}
}
}
};

@SuppressWarnings("ConstantConditions")
private void setupUI() {
findViewById(R.id.button_crop).setOnClickListener(new View.OnClickListener() {
Expand Down Expand Up @@ -188,44 +225,6 @@ public void onStopTrackingTouch(SeekBar seekBar) {
mEditTextMaxWidth.addTextChangedListener(mMaxSizeTextWatcher);
}


private TextWatcher mAspectRatioTextWatcher = new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
mRadioGroupAspectRatio.clearCheck();
}

@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {

}

@Override
public void afterTextChanged(Editable s) {

}
};

private TextWatcher mMaxSizeTextWatcher = new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}

@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {

}

@Override
public void afterTextChanged(Editable s) {
if (s != null && !s.toString().trim().isEmpty()) {
if (Integer.valueOf(s.toString()) < UCrop.MIN_SIZE) {
Toast.makeText(SampleActivity.this, String.format(getString(R.string.format_max_cropped_image_size), UCrop.MIN_SIZE), Toast.LENGTH_SHORT).show();
}
}
}
};

private void pickFromGallery() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN
&& ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE)
Expand Down Expand Up @@ -525,7 +524,7 @@ public boolean onCreateOptionsMenu(final Menu menu) {
}

MenuItem menuItemCrop = menu.findItem(R.id.menu_crop);
Drawable menuItemCropIcon = ContextCompat.getDrawable(this, mToolbarCropDrawable);
Drawable menuItemCropIcon = ContextCompat.getDrawable(this, mToolbarCropDrawable == 0 ? R.drawable.ucrop_ic_done : mToolbarCropDrawable);
if (menuItemCropIcon != null) {
menuItemCropIcon.mutate();
menuItemCropIcon.setColorFilter(mToolbarWidgetColor, PorterDuff.Mode.SRC_ATOP);
Expand All @@ -545,7 +544,7 @@ public boolean onPrepareOptionsMenu(Menu menu) {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.menu_crop) {
if (fragment.isAdded())
if (fragment != null && fragment.isAdded())
fragment.cropAndSaveImage();
} else if (item.getItemId() == android.R.id.home) {
removeFragmentFromScreen();
Expand Down
2 changes: 2 additions & 0 deletions sample/src/main/res/layout/include_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLength="9"
android:gravity="center"
android:hint="@string/label_width"
android:inputType="number" />
Expand All @@ -180,6 +181,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLength="9"
android:gravity="center"
android:hint="@string/label_height"
android:inputType="number" />
Expand Down
1 change: 1 addition & 0 deletions sample/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<string name="format_quality_d">Quality: %d</string>
<string name="format_d_d_px">%1$dx%2$d px</string>
<string name="format_max_cropped_image_size">Max cropped image size cannot be less then %d</string>
<string name="format_max_cropped_image_size_resolution">Too big resolution</string>

<string name="permission_title_rationale">Permission needed</string>
<string name="permission_read_storage_rationale">Storage read permission is needed to pick files.</string>
Expand Down
21 changes: 13 additions & 8 deletions ucrop/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ apply plugin: 'com.android.library'
apply from: '../mavenpush.gradle'

android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
compileSdkVersion 28
buildToolsVersion '28.0.3'

defaultConfig {
minSdkVersion 14
targetSdkVersion 27
versionCode 23
versionName "2.2.2-non-native"
targetSdkVersion 28
versionCode 24
versionName "2.2.3-non-native"

vectorDrawables.useSupportLibrary = true
}
Expand All @@ -32,7 +32,12 @@ android {
}

dependencies {
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support:exifinterface:27.1.0'
implementation 'com.squareup.okhttp3:okhttp:3.8.1'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:exifinterface:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.squareup.okhttp3:okhttp:3.11.0'
}

repositories {
google()
}
12 changes: 10 additions & 2 deletions ucrop/src/main/java/com/yalantis/ucrop/UCrop.java
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ public static int getOutputImageHeight(@NonNull Intent intent) {
* @return aspect ratio as a floating point value (x:y) - so it will be 1 for 1:1 or 4/3 for 4:3
*/
public static float getOutputCropAspectRatio(@NonNull Intent intent) {
return intent.getParcelableExtra(EXTRA_OUTPUT_CROP_ASPECT_RATIO);
return intent.getFloatExtra(EXTRA_OUTPUT_CROP_ASPECT_RATIO, 0f);
}

/**
Expand Down Expand Up @@ -282,6 +282,7 @@ public static class Options {
public static final String EXTRA_TOOL_BAR_COLOR = EXTRA_PREFIX + ".ToolbarColor";
public static final String EXTRA_STATUS_BAR_COLOR = EXTRA_PREFIX + ".StatusBarColor";
public static final String EXTRA_UCROP_COLOR_WIDGET_ACTIVE = EXTRA_PREFIX + ".UcropColorWidgetActive";
public static final String EXTRA_UCROP_COLOR_CONTROLS_WIDGET_ACTIVE = EXTRA_PREFIX + ".UcropColorControlsWidgetActive";

public static final String EXTRA_UCROP_WIDGET_COLOR_TOOLBAR = EXTRA_PREFIX + ".UcropToolbarWidgetColor";
public static final String EXTRA_UCROP_TITLE_TEXT_TOOLBAR = EXTRA_PREFIX + ".UcropToolbarTitleText";
Expand Down Expand Up @@ -445,12 +446,19 @@ public void setStatusBarColor(@ColorInt int color) {
}

/**
* @param color - desired resolved color of the active and selected widget (default is orange) and progress wheel middle line
* @param color - desired resolved color of the progress wheel middle line (default is violet)
*/
public void setActiveWidgetColor(@ColorInt int color) {
mOptionBundle.putInt(EXTRA_UCROP_COLOR_WIDGET_ACTIVE, color);
}

/**
* @param color - desired resolved color of the active and selected widget (default is white)
*/
public void setActiveControlsWidgetColor(@ColorInt int color) {
mOptionBundle.putInt(EXTRA_UCROP_COLOR_CONTROLS_WIDGET_ACTIVE, color);
}

/**
* @param color - desired resolved color of Toolbar text and buttons (default is darker orange)
*/
Expand Down
Loading

0 comments on commit 830d924

Please sign in to comment.