diff --git a/README.md b/README.md index 5bbfd1f30..d5b0e5764 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 diff --git a/build.gradle b/build.gradle index 9a0c7da21..3197b24c0 100644 --- a/build.gradle +++ b/build.gradle @@ -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' } } diff --git a/gradle.properties b/gradle.properties index 11d90f9cf..fad32fa34 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 9900a61ad..a7399a21d 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -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 diff --git a/sample/build.gradle b/sample/build.gradle index 8012fd242..37c3cc3de 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -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 { @@ -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') } \ No newline at end of file diff --git a/sample/src/main/java/com/yalantis/ucrop/sample/SampleActivity.java b/sample/src/main/java/com/yalantis/ucrop/sample/SampleActivity.java index c18a2c675..50bb08a76 100644 --- a/sample/src/main/java/com/yalantis/ucrop/sample/SampleActivity.java +++ b/sample/src/main/java/com/yalantis/ucrop/sample/SampleActivity.java @@ -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() { @@ -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) @@ -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); @@ -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(); diff --git a/sample/src/main/res/layout/include_settings.xml b/sample/src/main/res/layout/include_settings.xml index abdaae8bf..74f7a142d 100644 --- a/sample/src/main/res/layout/include_settings.xml +++ b/sample/src/main/res/layout/include_settings.xml @@ -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" /> @@ -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" /> diff --git a/sample/src/main/res/values/strings.xml b/sample/src/main/res/values/strings.xml index c77ebb6b4..77044f37c 100644 --- a/sample/src/main/res/values/strings.xml +++ b/sample/src/main/res/values/strings.xml @@ -33,6 +33,7 @@ Quality: %d %1$dx%2$d px Max cropped image size cannot be less then %d + Too big resolution Permission needed Storage read permission is needed to pick files. diff --git a/ucrop/build.gradle b/ucrop/build.gradle index 21e4f5ffa..93a73e2ad 100644 --- a/ucrop/build.gradle +++ b/ucrop/build.gradle @@ -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 } @@ -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() } diff --git a/ucrop/src/main/java/com/yalantis/ucrop/UCrop.java b/ucrop/src/main/java/com/yalantis/ucrop/UCrop.java index bb0e8fc99..54e9ad70c 100644 --- a/ucrop/src/main/java/com/yalantis/ucrop/UCrop.java +++ b/ucrop/src/main/java/com/yalantis/ucrop/UCrop.java @@ -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); } /** @@ -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"; @@ -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) */ diff --git a/ucrop/src/main/java/com/yalantis/ucrop/UCropActivity.java b/ucrop/src/main/java/com/yalantis/ucrop/UCropActivity.java index 8446f58c6..a8299874e 100644 --- a/ucrop/src/main/java/com/yalantis/ucrop/UCropActivity.java +++ b/ucrop/src/main/java/com/yalantis/ucrop/UCropActivity.java @@ -14,12 +14,16 @@ import android.support.annotation.IdRes; import android.support.annotation.IntDef; import android.support.annotation.NonNull; +import android.support.transition.AutoTransition; +import android.support.transition.Transition; +import android.support.transition.TransitionManager; import android.support.v4.content.ContextCompat; import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.text.TextUtils; import android.util.Log; +import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; import android.view.View; @@ -72,7 +76,7 @@ public class UCropActivity extends AppCompatActivity { } private static final String TAG = "UCropActivity"; - + private static final long CONTROLS_ANIMATION_DURATION = 50; private static final int TABS_COUNT = 3; private static final int SCALE_WIDGET_SENSITIVITY_COEFFICIENT = 15000; private static final int ROTATE_WIDGET_SENSITIVITY_COEFFICIENT = 42; @@ -83,6 +87,7 @@ public class UCropActivity extends AppCompatActivity { private int mToolbarColor; private int mStatusBarColor; private int mActiveWidgetColor; + private int mActiveControlsWidgetColor; private int mToolbarWidgetColor; @ColorInt private int mRootViewBackgroundColor; @@ -104,6 +109,8 @@ public class UCropActivity extends AppCompatActivity { private TextView mTextViewRotateAngle, mTextViewScalePercent; private View mBlockingView; + private Transition mControlsTransition; + private Bitmap.CompressFormat mCompressFormat = DEFAULT_COMPRESS_FORMAT; private int mCompressQuality = DEFAULT_COMPRESS_QUALITY; private int[] mAllowedGestures = new int[]{SCALE, ROTATE, ALL}; @@ -274,7 +281,9 @@ private void processOptions(@NonNull Intent intent) { private void setupViews(@NonNull Intent intent) { mStatusBarColor = intent.getIntExtra(UCrop.Options.EXTRA_STATUS_BAR_COLOR, ContextCompat.getColor(this, R.color.ucrop_color_statusbar)); mToolbarColor = intent.getIntExtra(UCrop.Options.EXTRA_TOOL_BAR_COLOR, ContextCompat.getColor(this, R.color.ucrop_color_toolbar)); - mActiveWidgetColor = intent.getIntExtra(UCrop.Options.EXTRA_UCROP_COLOR_WIDGET_ACTIVE, ContextCompat.getColor(this, R.color.ucrop_color_widget_active)); + mActiveWidgetColor = intent.getIntExtra(UCrop.Options.EXTRA_UCROP_COLOR_WIDGET_ACTIVE, ContextCompat.getColor(this, R.color.ucrop_color_widget_background)); + mActiveControlsWidgetColor = intent.getIntExtra(UCrop.Options.EXTRA_UCROP_COLOR_CONTROLS_WIDGET_ACTIVE, ContextCompat.getColor(this, R.color.ucrop_color_active_controls_color)); + mToolbarWidgetColor = intent.getIntExtra(UCrop.Options.EXTRA_UCROP_WIDGET_COLOR_TOOLBAR, ContextCompat.getColor(this, R.color.ucrop_color_toolbar_widget)); mToolbarCancelDrawable = intent.getIntExtra(UCrop.Options.EXTRA_UCROP_WIDGET_CANCEL_DRAWABLE, R.drawable.ucrop_ic_cross); mToolbarCropDrawable = intent.getIntExtra(UCrop.Options.EXTRA_UCROP_WIDGET_CROP_DRAWABLE, R.drawable.ucrop_ic_done); @@ -288,8 +297,15 @@ private void setupViews(@NonNull Intent intent) { initiateRootViews(); if (mShowBottomControls) { - ViewGroup photoBox = findViewById(R.id.ucrop_photobox); - View.inflate(this, R.layout.ucrop_controls, photoBox); + + ViewGroup viewGroup = findViewById(R.id.ucrop_photobox); + ViewGroup wrapper = viewGroup.findViewById(R.id.controls_wrapper); + wrapper.setVisibility(View.VISIBLE); + wrapper.setBackgroundColor(mRootViewBackgroundColor); + LayoutInflater.from(this).inflate(R.layout.ucrop_controls, wrapper, true); + + mControlsTransition = new AutoTransition(); + mControlsTransition.setDuration(CONTROLS_ANIMATION_DURATION); mWrapperStateAspectRatio = findViewById(R.id.state_aspect_ratio); mWrapperStateAspectRatio.setOnClickListener(mStateClickListener); @@ -384,9 +400,9 @@ private void setupStatesWrapper() { ImageView stateRotateImageView = findViewById(R.id.image_view_state_rotate); ImageView stateAspectRatioImageView = findViewById(R.id.image_view_state_aspect_ratio); - stateScaleImageView.setImageDrawable(new SelectedStateListDrawable(stateScaleImageView.getDrawable(), mActiveWidgetColor)); - stateRotateImageView.setImageDrawable(new SelectedStateListDrawable(stateRotateImageView.getDrawable(), mActiveWidgetColor)); - stateAspectRatioImageView.setImageDrawable(new SelectedStateListDrawable(stateAspectRatioImageView.getDrawable(), mActiveWidgetColor)); + stateScaleImageView.setImageDrawable(new SelectedStateListDrawable(stateScaleImageView.getDrawable(), mActiveControlsWidgetColor)); + stateRotateImageView.setImageDrawable(new SelectedStateListDrawable(stateRotateImageView.getDrawable(), mActiveControlsWidgetColor)); + stateAspectRatioImageView.setImageDrawable(new SelectedStateListDrawable(stateAspectRatioImageView.getDrawable(), mActiveControlsWidgetColor)); } @@ -578,6 +594,8 @@ private void setWidgetState(@IdRes int stateViewId) { mLayoutRotate.setVisibility(stateViewId == R.id.state_rotate ? View.VISIBLE : View.GONE); mLayoutScale.setVisibility(stateViewId == R.id.state_scale ? View.VISIBLE : View.GONE); + changeSelectedTab(stateViewId); + if (stateViewId == R.id.state_scale) { setAllowedGestures(0); } else if (stateViewId == R.id.state_rotate) { @@ -587,6 +605,15 @@ private void setWidgetState(@IdRes int stateViewId) { } } + private void changeSelectedTab(int stateViewId) { + TransitionManager.beginDelayedTransition((ViewGroup) findViewById(R.id.ucrop_photobox), mControlsTransition); + + mWrapperStateScale.findViewById(R.id.text_view_scale).setVisibility(stateViewId == R.id.state_scale ? View.VISIBLE : View.GONE); + mWrapperStateAspectRatio.findViewById(R.id.text_view_crop).setVisibility(stateViewId == R.id.state_aspect_ratio ? View.VISIBLE : View.GONE); + mWrapperStateRotate.findViewById(R.id.text_view_rotate).setVisibility(stateViewId == R.id.state_rotate ? View.VISIBLE : View.GONE); + + } + private void setAllowedGestures(int tab) { mGestureCropImageView.setScaleEnabled(mAllowedGestures[tab] == ALL || mAllowedGestures[tab] == SCALE); mGestureCropImageView.setRotateEnabled(mAllowedGestures[tab] == ALL || mAllowedGestures[tab] == ROTATE); diff --git a/ucrop/src/main/java/com/yalantis/ucrop/UCropFragment.java b/ucrop/src/main/java/com/yalantis/ucrop/UCropFragment.java index 2e64450c4..cd59e6992 100644 --- a/ucrop/src/main/java/com/yalantis/ucrop/UCropFragment.java +++ b/ucrop/src/main/java/com/yalantis/ucrop/UCropFragment.java @@ -11,6 +11,9 @@ import android.support.annotation.IntDef; import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import android.support.transition.AutoTransition; +import android.support.transition.Transition; +import android.support.transition.TransitionManager; import android.support.v4.app.Fragment; import android.support.v4.content.ContextCompat; import android.text.TextUtils; @@ -61,11 +64,13 @@ public class UCropFragment extends Fragment { public static final String TAG = "UCropFragment"; + private static final long CONTROLS_ANIMATION_DURATION = 50; private static final int TABS_COUNT = 3; private static final int SCALE_WIDGET_SENSITIVITY_COEFFICIENT = 15000; private static final int ROTATE_WIDGET_SENSITIVITY_COEFFICIENT = 42; private UCropFragmentCallback callback; + private int mActiveControlsWidgetColor; private int mActiveWidgetColor; @ColorInt private int mRootViewBackgroundColor; @@ -73,6 +78,8 @@ public class UCropFragment extends Fragment { private boolean mShowBottomControls; + private Transition mControlsTransition; + private UCropView mUCropView; private GestureCropImageView mGestureCropImageView; private OverlayView mOverlayView; @@ -95,12 +102,13 @@ public static UCropFragment newInstance(Bundle uCrop) { @Override public void onAttach(Context context) { super.onAttach(context); - try { + if (getParentFragment() instanceof UCropFragmentCallback) + callback = (UCropFragmentCallback) getParentFragment(); + else if (context instanceof UCropFragmentCallback) callback = (UCropFragmentCallback) context; - } catch (ClassCastException e) { - throw new ClassCastException(context.toString() + else + throw new IllegalArgumentException(context.toString() + " must implement UCropFragmentCallback"); - } } public void setCallback(UCropFragmentCallback callback) { @@ -124,7 +132,8 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c public void setupViews(View view, Bundle args) { - mActiveWidgetColor = args.getInt(UCrop.Options.EXTRA_UCROP_COLOR_WIDGET_ACTIVE, ContextCompat.getColor(getContext(), R.color.ucrop_color_widget_active)); + mActiveWidgetColor = args.getInt(UCrop.Options.EXTRA_UCROP_COLOR_WIDGET_ACTIVE, ContextCompat.getColor(getContext(), R.color.ucrop_color_widget_background)); + mActiveControlsWidgetColor = args.getInt(UCrop.Options.EXTRA_UCROP_COLOR_WIDGET_ACTIVE, ContextCompat.getColor(getContext(), R.color.ucrop_color_widget_active)); mLogoColor = args.getInt(UCrop.Options.EXTRA_UCROP_LOGO_COLOR, ContextCompat.getColor(getContext(), R.color.ucrop_color_default_logo)); mShowBottomControls = !args.getBoolean(UCrop.Options.EXTRA_HIDE_BOTTOM_CONTROLS, false); mRootViewBackgroundColor = args.getInt(UCrop.Options.EXTRA_UCROP_ROOT_VIEW_BACKGROUND_COLOR, ContextCompat.getColor(getContext(), R.color.ucrop_color_crop_background)); @@ -133,8 +142,14 @@ public void setupViews(View view, Bundle args) { callback.loadingProgress(true); if (mShowBottomControls) { - ViewGroup photoBox = view.findViewById(R.id.ucrop_photobox); - View.inflate(getContext(), R.layout.ucrop_controls, photoBox); + + ViewGroup wrapper = view.findViewById(R.id.controls_wrapper); + wrapper.setVisibility(View.VISIBLE); + wrapper.setBackgroundColor(mRootViewBackgroundColor); + LayoutInflater.from(getContext()).inflate(R.layout.ucrop_controls, wrapper, true); + + mControlsTransition = new AutoTransition(); + mControlsTransition.setDuration(CONTROLS_ANIMATION_DURATION); mWrapperStateAspectRatio = view.findViewById(R.id.state_aspect_ratio); mWrapperStateAspectRatio.setOnClickListener(mStateClickListener); @@ -287,9 +302,9 @@ private void setupStatesWrapper(View view) { ImageView stateRotateImageView = view.findViewById(R.id.image_view_state_rotate); ImageView stateAspectRatioImageView = view.findViewById(R.id.image_view_state_aspect_ratio); - stateScaleImageView.setImageDrawable(new SelectedStateListDrawable(stateScaleImageView.getDrawable(), mActiveWidgetColor)); - stateRotateImageView.setImageDrawable(new SelectedStateListDrawable(stateRotateImageView.getDrawable(), mActiveWidgetColor)); - stateAspectRatioImageView.setImageDrawable(new SelectedStateListDrawable(stateAspectRatioImageView.getDrawable(), mActiveWidgetColor)); + stateScaleImageView.setImageDrawable(new SelectedStateListDrawable(stateScaleImageView.getDrawable(), mActiveControlsWidgetColor)); + stateRotateImageView.setImageDrawable(new SelectedStateListDrawable(stateRotateImageView.getDrawable(), mActiveControlsWidgetColor)); + stateAspectRatioImageView.setImageDrawable(new SelectedStateListDrawable(stateAspectRatioImageView.getDrawable(), mActiveControlsWidgetColor)); } private void setupAspectRatioWidget(@NonNull Bundle bundle, View view) { @@ -463,6 +478,8 @@ private void setWidgetState(@IdRes int stateViewId) { mLayoutRotate.setVisibility(stateViewId == R.id.state_rotate ? View.VISIBLE : View.GONE); mLayoutScale.setVisibility(stateViewId == R.id.state_scale ? View.VISIBLE : View.GONE); + changeSelectedTab(stateViewId); + if (stateViewId == R.id.state_scale) { setAllowedGestures(0); } else if (stateViewId == R.id.state_rotate) { @@ -472,6 +489,15 @@ private void setWidgetState(@IdRes int stateViewId) { } } + private void changeSelectedTab(int stateViewId) { + if (getView() != null) { + TransitionManager.beginDelayedTransition((ViewGroup) getView().findViewById(R.id.ucrop_photobox), mControlsTransition); + } + mWrapperStateScale.findViewById(R.id.text_view_scale).setVisibility(stateViewId == R.id.state_scale ? View.VISIBLE : View.GONE); + mWrapperStateAspectRatio.findViewById(R.id.text_view_crop).setVisibility(stateViewId == R.id.state_aspect_ratio ? View.VISIBLE : View.GONE); + mWrapperStateRotate.findViewById(R.id.text_view_rotate).setVisibility(stateViewId == R.id.state_rotate ? View.VISIBLE : View.GONE); + } + private void setAllowedGestures(int tab) { mGestureCropImageView.setScaleEnabled(mAllowedGestures[tab] == ALL || mAllowedGestures[tab] == SCALE); mGestureCropImageView.setRotateEnabled(mAllowedGestures[tab] == ALL || mAllowedGestures[tab] == ROTATE); diff --git a/ucrop/src/main/java/com/yalantis/ucrop/task/BitmapCropTask.java b/ucrop/src/main/java/com/yalantis/ucrop/task/BitmapCropTask.java index 3de4ef54f..b41a51566 100644 --- a/ucrop/src/main/java/com/yalantis/ucrop/task/BitmapCropTask.java +++ b/ucrop/src/main/java/com/yalantis/ucrop/task/BitmapCropTask.java @@ -90,7 +90,6 @@ protected Throwable doInBackground(Void... params) { return new NullPointerException("CurrentImageRect is empty"); } - try { crop(); mViewBitmap = null; @@ -101,7 +100,6 @@ protected Throwable doInBackground(Void... params) { return null; } - private boolean crop() throws IOException { // Downsize if needed if (mMaxResultImageSizeX > 0 && mMaxResultImageSizeY > 0) { diff --git a/ucrop/src/main/java/com/yalantis/ucrop/view/UCropView.java b/ucrop/src/main/java/com/yalantis/ucrop/view/UCropView.java index 5de97f3d0..4b77f2d66 100644 --- a/ucrop/src/main/java/com/yalantis/ucrop/view/UCropView.java +++ b/ucrop/src/main/java/com/yalantis/ucrop/view/UCropView.java @@ -25,8 +25,8 @@ public UCropView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); LayoutInflater.from(context).inflate(R.layout.ucrop_view, this, true); - mGestureCropImageView = (GestureCropImageView) findViewById(R.id.image_view_crop); - mViewOverlay = (OverlayView) findViewById(R.id.view_overlay); + mGestureCropImageView = findViewById(R.id.image_view_crop); + mViewOverlay = findViewById(R.id.view_overlay); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ucrop_UCropView); mViewOverlay.processStyledAttributes(a); diff --git a/ucrop/src/main/java/com/yalantis/ucrop/view/widget/AspectRatioTextView.java b/ucrop/src/main/java/com/yalantis/ucrop/view/widget/AspectRatioTextView.java index 43397f49d..3083e55fb 100644 --- a/ucrop/src/main/java/com/yalantis/ucrop/view/widget/AspectRatioTextView.java +++ b/ucrop/src/main/java/com/yalantis/ucrop/view/widget/AspectRatioTextView.java @@ -27,6 +27,7 @@ */ public class AspectRatioTextView extends TextView { + private final float MARGIN_MULTIPLIER = 1.5f; private final Rect mCanvasClipBounds = new Rect(); private Paint mDotPaint; private int mDotSize; @@ -93,8 +94,11 @@ protected void onDraw(Canvas canvas) { if (isSelected()) { canvas.getClipBounds(mCanvasClipBounds); - canvas.drawCircle((mCanvasClipBounds.right - mCanvasClipBounds.left) / 2.0f, mCanvasClipBounds.bottom - mDotSize, - mDotSize / 2, mDotPaint); + + float x = (mCanvasClipBounds.right - mCanvasClipBounds.left) / 2.0f; + float y = (mCanvasClipBounds.bottom - mCanvasClipBounds.top / 2f) - mDotSize * MARGIN_MULTIPLIER; + + canvas.drawCircle(x, y, mDotSize / 2f, mDotPaint); } } diff --git a/ucrop/src/main/java/com/yalantis/ucrop/view/widget/HorizontalProgressWheelView.java b/ucrop/src/main/java/com/yalantis/ucrop/view/widget/HorizontalProgressWheelView.java index 42f1cd740..ed724f70a 100644 --- a/ucrop/src/main/java/com/yalantis/ucrop/view/widget/HorizontalProgressWheelView.java +++ b/ucrop/src/main/java/com/yalantis/ucrop/view/widget/HorizontalProgressWheelView.java @@ -25,6 +25,7 @@ public class HorizontalProgressWheelView extends View { private float mLastTouchedPosition; private Paint mProgressLinePaint; + private Paint mProgressMiddleLinePaint; private int mProgressLineWidth, mProgressLineHeight; private int mProgressLineMargin; @@ -96,7 +97,6 @@ protected void onDraw(Canvas canvas) { int linesCount = mCanvasClipBounds.width() / (mProgressLineWidth + mProgressLineMargin); float deltaX = (mTotalScrollDistance) % (float) (mProgressLineMargin + mProgressLineWidth); - mProgressLinePaint.setColor(getResources().getColor(R.color.ucrop_color_progress_wheel_line)); for (int i = 0; i < linesCount; i++) { if (i < (linesCount / 4)) { mProgressLinePaint.setAlpha((int) (255 * (i / (float) (linesCount / 4)))); @@ -112,8 +112,7 @@ protected void onDraw(Canvas canvas) { mCanvasClipBounds.centerY() + mProgressLineHeight / 4.0f, mProgressLinePaint); } - mProgressLinePaint.setColor(mMiddleLineColor); - canvas.drawLine(mCanvasClipBounds.centerX(), mCanvasClipBounds.centerY() - mProgressLineHeight / 2.0f, mCanvasClipBounds.centerX(), mCanvasClipBounds.centerY() + mProgressLineHeight / 2.0f, mProgressLinePaint); + canvas.drawLine(mCanvasClipBounds.centerX(), mCanvasClipBounds.centerY() - mProgressLineHeight / 2.0f, mCanvasClipBounds.centerX(), mCanvasClipBounds.centerY() + mProgressLineHeight / 2.0f, mProgressMiddleLinePaint); } @@ -127,7 +126,7 @@ private void onScrollEvent(MotionEvent event, float distance) { } private void init() { - mMiddleLineColor = ContextCompat.getColor(getContext(), R.color.ucrop_color_progress_wheel_line); + mMiddleLineColor = ContextCompat.getColor(getContext(), R.color.ucrop_color_widget_rotate_mid_line); mProgressLineWidth = getContext().getResources().getDimensionPixelSize(R.dimen.ucrop_width_horizontal_wheel_progress_line); mProgressLineHeight = getContext().getResources().getDimensionPixelSize(R.dimen.ucrop_height_horizontal_wheel_progress_line); @@ -136,7 +135,12 @@ private void init() { mProgressLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG); mProgressLinePaint.setStyle(Paint.Style.STROKE); mProgressLinePaint.setStrokeWidth(mProgressLineWidth); + mProgressLinePaint.setColor(getResources().getColor(R.color.ucrop_color_progress_wheel_line)); + mProgressMiddleLinePaint = new Paint(mProgressLinePaint); + mProgressMiddleLinePaint.setColor(mMiddleLineColor); + mProgressMiddleLinePaint.setStrokeCap(Paint.Cap.ROUND); + mProgressMiddleLinePaint.setStrokeWidth(getContext().getResources().getDimensionPixelSize(R.dimen.ucrop_width_middle_wheel_progress_line)); } public interface ScrollingListener { diff --git a/ucrop/src/main/res/drawable-hdpi/ucrop_ic_crop.png b/ucrop/src/main/res/drawable-hdpi/ucrop_ic_crop.png deleted file mode 100644 index a12fdfc7c..000000000 Binary files a/ucrop/src/main/res/drawable-hdpi/ucrop_ic_crop.png and /dev/null differ diff --git a/ucrop/src/main/res/drawable-hdpi/ucrop_ic_cross.png b/ucrop/src/main/res/drawable-hdpi/ucrop_ic_cross.png deleted file mode 100644 index c0e8de803..000000000 Binary files a/ucrop/src/main/res/drawable-hdpi/ucrop_ic_cross.png and /dev/null differ diff --git a/ucrop/src/main/res/drawable-hdpi/ucrop_ic_next.png b/ucrop/src/main/res/drawable-hdpi/ucrop_ic_next.png deleted file mode 100644 index d1b1cddb7..000000000 Binary files a/ucrop/src/main/res/drawable-hdpi/ucrop_ic_next.png and /dev/null differ diff --git a/ucrop/src/main/res/drawable-hdpi/ucrop_ic_reset.png b/ucrop/src/main/res/drawable-hdpi/ucrop_ic_reset.png deleted file mode 100644 index 2b6692bbd..000000000 Binary files a/ucrop/src/main/res/drawable-hdpi/ucrop_ic_reset.png and /dev/null differ diff --git a/ucrop/src/main/res/drawable-hdpi/ucrop_ic_rotate.png b/ucrop/src/main/res/drawable-hdpi/ucrop_ic_rotate.png deleted file mode 100644 index ba20cf35d..000000000 Binary files a/ucrop/src/main/res/drawable-hdpi/ucrop_ic_rotate.png and /dev/null differ diff --git a/ucrop/src/main/res/drawable-hdpi/ucrop_ic_scale.png b/ucrop/src/main/res/drawable-hdpi/ucrop_ic_scale.png deleted file mode 100644 index 0be967cd2..000000000 Binary files a/ucrop/src/main/res/drawable-hdpi/ucrop_ic_scale.png and /dev/null differ diff --git a/ucrop/src/main/res/drawable-ldpi/ucrop_ic_crop.png b/ucrop/src/main/res/drawable-ldpi/ucrop_ic_crop.png deleted file mode 100644 index 19daec377..000000000 Binary files a/ucrop/src/main/res/drawable-ldpi/ucrop_ic_crop.png and /dev/null differ diff --git a/ucrop/src/main/res/drawable-ldpi/ucrop_ic_cross.png b/ucrop/src/main/res/drawable-ldpi/ucrop_ic_cross.png deleted file mode 100644 index 69bb6ec89..000000000 Binary files a/ucrop/src/main/res/drawable-ldpi/ucrop_ic_cross.png and /dev/null differ diff --git a/ucrop/src/main/res/drawable-ldpi/ucrop_ic_next.png b/ucrop/src/main/res/drawable-ldpi/ucrop_ic_next.png deleted file mode 100644 index 732e9a780..000000000 Binary files a/ucrop/src/main/res/drawable-ldpi/ucrop_ic_next.png and /dev/null differ diff --git a/ucrop/src/main/res/drawable-ldpi/ucrop_ic_reset.png b/ucrop/src/main/res/drawable-ldpi/ucrop_ic_reset.png deleted file mode 100644 index dfdb5bc9c..000000000 Binary files a/ucrop/src/main/res/drawable-ldpi/ucrop_ic_reset.png and /dev/null differ diff --git a/ucrop/src/main/res/drawable-ldpi/ucrop_ic_rotate.png b/ucrop/src/main/res/drawable-ldpi/ucrop_ic_rotate.png deleted file mode 100644 index d812eada9..000000000 Binary files a/ucrop/src/main/res/drawable-ldpi/ucrop_ic_rotate.png and /dev/null differ diff --git a/ucrop/src/main/res/drawable-ldpi/ucrop_ic_scale.png b/ucrop/src/main/res/drawable-ldpi/ucrop_ic_scale.png deleted file mode 100644 index 2522ac7db..000000000 Binary files a/ucrop/src/main/res/drawable-ldpi/ucrop_ic_scale.png and /dev/null differ diff --git a/ucrop/src/main/res/drawable-mdpi/ucrop_ic_crop.png b/ucrop/src/main/res/drawable-mdpi/ucrop_ic_crop.png deleted file mode 100644 index 36e4f362a..000000000 Binary files a/ucrop/src/main/res/drawable-mdpi/ucrop_ic_crop.png and /dev/null differ diff --git a/ucrop/src/main/res/drawable-mdpi/ucrop_ic_cross.png b/ucrop/src/main/res/drawable-mdpi/ucrop_ic_cross.png deleted file mode 100644 index a2da5b960..000000000 Binary files a/ucrop/src/main/res/drawable-mdpi/ucrop_ic_cross.png and /dev/null differ diff --git a/ucrop/src/main/res/drawable-mdpi/ucrop_ic_next.png b/ucrop/src/main/res/drawable-mdpi/ucrop_ic_next.png deleted file mode 100644 index 8f972bb0b..000000000 Binary files a/ucrop/src/main/res/drawable-mdpi/ucrop_ic_next.png and /dev/null differ diff --git a/ucrop/src/main/res/drawable-mdpi/ucrop_ic_reset.png b/ucrop/src/main/res/drawable-mdpi/ucrop_ic_reset.png deleted file mode 100644 index 5431cd34f..000000000 Binary files a/ucrop/src/main/res/drawable-mdpi/ucrop_ic_reset.png and /dev/null differ diff --git a/ucrop/src/main/res/drawable-mdpi/ucrop_ic_rotate.png b/ucrop/src/main/res/drawable-mdpi/ucrop_ic_rotate.png deleted file mode 100644 index f78900666..000000000 Binary files a/ucrop/src/main/res/drawable-mdpi/ucrop_ic_rotate.png and /dev/null differ diff --git a/ucrop/src/main/res/drawable-mdpi/ucrop_ic_scale.png b/ucrop/src/main/res/drawable-mdpi/ucrop_ic_scale.png deleted file mode 100644 index ac363b773..000000000 Binary files a/ucrop/src/main/res/drawable-mdpi/ucrop_ic_scale.png and /dev/null differ diff --git a/ucrop/src/main/res/drawable-xhdpi/ucrop_ic_crop.png b/ucrop/src/main/res/drawable-xhdpi/ucrop_ic_crop.png deleted file mode 100644 index f18a41c33..000000000 Binary files a/ucrop/src/main/res/drawable-xhdpi/ucrop_ic_crop.png and /dev/null differ diff --git a/ucrop/src/main/res/drawable-xhdpi/ucrop_ic_cross.png b/ucrop/src/main/res/drawable-xhdpi/ucrop_ic_cross.png deleted file mode 100644 index 443430be6..000000000 Binary files a/ucrop/src/main/res/drawable-xhdpi/ucrop_ic_cross.png and /dev/null differ diff --git a/ucrop/src/main/res/drawable-xhdpi/ucrop_ic_next.png b/ucrop/src/main/res/drawable-xhdpi/ucrop_ic_next.png deleted file mode 100644 index 6cd8e2942..000000000 Binary files a/ucrop/src/main/res/drawable-xhdpi/ucrop_ic_next.png and /dev/null differ diff --git a/ucrop/src/main/res/drawable-xhdpi/ucrop_ic_reset.png b/ucrop/src/main/res/drawable-xhdpi/ucrop_ic_reset.png deleted file mode 100644 index 15f8a7b2d..000000000 Binary files a/ucrop/src/main/res/drawable-xhdpi/ucrop_ic_reset.png and /dev/null differ diff --git a/ucrop/src/main/res/drawable-xhdpi/ucrop_ic_rotate.png b/ucrop/src/main/res/drawable-xhdpi/ucrop_ic_rotate.png deleted file mode 100644 index d10f0c996..000000000 Binary files a/ucrop/src/main/res/drawable-xhdpi/ucrop_ic_rotate.png and /dev/null differ diff --git a/ucrop/src/main/res/drawable-xhdpi/ucrop_ic_scale.png b/ucrop/src/main/res/drawable-xhdpi/ucrop_ic_scale.png deleted file mode 100644 index cdb822575..000000000 Binary files a/ucrop/src/main/res/drawable-xhdpi/ucrop_ic_scale.png and /dev/null differ diff --git a/ucrop/src/main/res/drawable-xxhdpi/ucrop_ic_crop.png b/ucrop/src/main/res/drawable-xxhdpi/ucrop_ic_crop.png deleted file mode 100644 index 7decf1a39..000000000 Binary files a/ucrop/src/main/res/drawable-xxhdpi/ucrop_ic_crop.png and /dev/null differ diff --git a/ucrop/src/main/res/drawable-xxhdpi/ucrop_ic_cross.png b/ucrop/src/main/res/drawable-xxhdpi/ucrop_ic_cross.png deleted file mode 100644 index 169e0c376..000000000 Binary files a/ucrop/src/main/res/drawable-xxhdpi/ucrop_ic_cross.png and /dev/null differ diff --git a/ucrop/src/main/res/drawable-xxhdpi/ucrop_ic_next.png b/ucrop/src/main/res/drawable-xxhdpi/ucrop_ic_next.png deleted file mode 100644 index d6f68f376..000000000 Binary files a/ucrop/src/main/res/drawable-xxhdpi/ucrop_ic_next.png and /dev/null differ diff --git a/ucrop/src/main/res/drawable-xxhdpi/ucrop_ic_reset.png b/ucrop/src/main/res/drawable-xxhdpi/ucrop_ic_reset.png deleted file mode 100644 index 52870ba0a..000000000 Binary files a/ucrop/src/main/res/drawable-xxhdpi/ucrop_ic_reset.png and /dev/null differ diff --git a/ucrop/src/main/res/drawable-xxhdpi/ucrop_ic_rotate.png b/ucrop/src/main/res/drawable-xxhdpi/ucrop_ic_rotate.png deleted file mode 100644 index 91b1c8ed1..000000000 Binary files a/ucrop/src/main/res/drawable-xxhdpi/ucrop_ic_rotate.png and /dev/null differ diff --git a/ucrop/src/main/res/drawable-xxhdpi/ucrop_ic_scale.png b/ucrop/src/main/res/drawable-xxhdpi/ucrop_ic_scale.png deleted file mode 100644 index 158335cc3..000000000 Binary files a/ucrop/src/main/res/drawable-xxhdpi/ucrop_ic_scale.png and /dev/null differ diff --git a/ucrop/src/main/res/drawable-xxxhdpi/ucrop_ic_crop.png b/ucrop/src/main/res/drawable-xxxhdpi/ucrop_ic_crop.png deleted file mode 100644 index 8dfce8836..000000000 Binary files a/ucrop/src/main/res/drawable-xxxhdpi/ucrop_ic_crop.png and /dev/null differ diff --git a/ucrop/src/main/res/drawable-xxxhdpi/ucrop_ic_cross.png b/ucrop/src/main/res/drawable-xxxhdpi/ucrop_ic_cross.png deleted file mode 100644 index 9e3226e1e..000000000 Binary files a/ucrop/src/main/res/drawable-xxxhdpi/ucrop_ic_cross.png and /dev/null differ diff --git a/ucrop/src/main/res/drawable-xxxhdpi/ucrop_ic_next.png b/ucrop/src/main/res/drawable-xxxhdpi/ucrop_ic_next.png deleted file mode 100644 index 9f6453402..000000000 Binary files a/ucrop/src/main/res/drawable-xxxhdpi/ucrop_ic_next.png and /dev/null differ diff --git a/ucrop/src/main/res/drawable-xxxhdpi/ucrop_ic_reset.png b/ucrop/src/main/res/drawable-xxxhdpi/ucrop_ic_reset.png deleted file mode 100644 index 75a92c0d2..000000000 Binary files a/ucrop/src/main/res/drawable-xxxhdpi/ucrop_ic_reset.png and /dev/null differ diff --git a/ucrop/src/main/res/drawable-xxxhdpi/ucrop_ic_rotate.png b/ucrop/src/main/res/drawable-xxxhdpi/ucrop_ic_rotate.png deleted file mode 100644 index 7525f9267..000000000 Binary files a/ucrop/src/main/res/drawable-xxxhdpi/ucrop_ic_rotate.png and /dev/null differ diff --git a/ucrop/src/main/res/drawable-xxxhdpi/ucrop_ic_scale.png b/ucrop/src/main/res/drawable-xxxhdpi/ucrop_ic_scale.png deleted file mode 100644 index 21fc505b9..000000000 Binary files a/ucrop/src/main/res/drawable-xxxhdpi/ucrop_ic_scale.png and /dev/null differ diff --git a/ucrop/src/main/res/drawable/ucrop_crop.xml b/ucrop/src/main/res/drawable/ucrop_crop.xml new file mode 100644 index 000000000..b0f03d506 --- /dev/null +++ b/ucrop/src/main/res/drawable/ucrop_crop.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/ucrop/src/main/res/drawable/ucrop_ic_crop.xml b/ucrop/src/main/res/drawable/ucrop_ic_crop.xml new file mode 100644 index 000000000..a85a66c36 --- /dev/null +++ b/ucrop/src/main/res/drawable/ucrop_ic_crop.xml @@ -0,0 +1,10 @@ + + + diff --git a/ucrop/src/main/res/drawable/ucrop_ic_crop_unselected.xml b/ucrop/src/main/res/drawable/ucrop_ic_crop_unselected.xml new file mode 100644 index 000000000..e931bc08c --- /dev/null +++ b/ucrop/src/main/res/drawable/ucrop_ic_crop_unselected.xml @@ -0,0 +1,11 @@ + + + diff --git a/ucrop/src/main/res/drawable/ucrop_ic_cross.xml b/ucrop/src/main/res/drawable/ucrop_ic_cross.xml new file mode 100644 index 000000000..5a38800ac --- /dev/null +++ b/ucrop/src/main/res/drawable/ucrop_ic_cross.xml @@ -0,0 +1,10 @@ + + + diff --git a/ucrop/src/main/res/drawable/ucrop_ic_next.xml b/ucrop/src/main/res/drawable/ucrop_ic_next.xml new file mode 100644 index 000000000..3110210a1 --- /dev/null +++ b/ucrop/src/main/res/drawable/ucrop_ic_next.xml @@ -0,0 +1,10 @@ + + + diff --git a/ucrop/src/main/res/drawable/ucrop_ic_reset.xml b/ucrop/src/main/res/drawable/ucrop_ic_reset.xml new file mode 100644 index 000000000..07e0845d7 --- /dev/null +++ b/ucrop/src/main/res/drawable/ucrop_ic_reset.xml @@ -0,0 +1,10 @@ + + + diff --git a/ucrop/src/main/res/drawable/ucrop_ic_rotate.xml b/ucrop/src/main/res/drawable/ucrop_ic_rotate.xml new file mode 100644 index 000000000..01da8e0e1 --- /dev/null +++ b/ucrop/src/main/res/drawable/ucrop_ic_rotate.xml @@ -0,0 +1,10 @@ + + + diff --git a/ucrop/src/main/res/drawable/ucrop_ic_rotate_unselected.xml b/ucrop/src/main/res/drawable/ucrop_ic_rotate_unselected.xml new file mode 100644 index 000000000..be4d9ea4b --- /dev/null +++ b/ucrop/src/main/res/drawable/ucrop_ic_rotate_unselected.xml @@ -0,0 +1,11 @@ + + + diff --git a/ucrop/src/main/res/drawable/ucrop_ic_scale.xml b/ucrop/src/main/res/drawable/ucrop_ic_scale.xml new file mode 100644 index 000000000..e038d52da --- /dev/null +++ b/ucrop/src/main/res/drawable/ucrop_ic_scale.xml @@ -0,0 +1,10 @@ + + + diff --git a/ucrop/src/main/res/drawable/ucrop_ic_scale_unselected.xml b/ucrop/src/main/res/drawable/ucrop_ic_scale_unselected.xml new file mode 100644 index 000000000..988b8d24d --- /dev/null +++ b/ucrop/src/main/res/drawable/ucrop_ic_scale_unselected.xml @@ -0,0 +1,11 @@ + + + diff --git a/ucrop/src/main/res/drawable/ucrop_rotate.xml b/ucrop/src/main/res/drawable/ucrop_rotate.xml new file mode 100644 index 000000000..9fe531363 --- /dev/null +++ b/ucrop/src/main/res/drawable/ucrop_rotate.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/ucrop/src/main/res/drawable/ucrop_scale.xml b/ucrop/src/main/res/drawable/ucrop_scale.xml new file mode 100644 index 000000000..05a1ad83c --- /dev/null +++ b/ucrop/src/main/res/drawable/ucrop_scale.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/ucrop/src/main/res/drawable/ucrop_shadow_upside.xml b/ucrop/src/main/res/drawable/ucrop_shadow_upside.xml index 0be54272f..3a05b825c 100644 --- a/ucrop/src/main/res/drawable/ucrop_shadow_upside.xml +++ b/ucrop/src/main/res/drawable/ucrop_shadow_upside.xml @@ -2,6 +2,6 @@ android:shape="rectangle"> \ No newline at end of file diff --git a/ucrop/src/main/res/drawable/ucrop_wrapper_controls_shape.xml b/ucrop/src/main/res/drawable/ucrop_wrapper_controls_shape.xml new file mode 100644 index 000000000..b44a0f0b1 --- /dev/null +++ b/ucrop/src/main/res/drawable/ucrop_wrapper_controls_shape.xml @@ -0,0 +1,10 @@ + + + + + + + \ No newline at end of file diff --git a/ucrop/src/main/res/layout/ucrop_activity_photobox.xml b/ucrop/src/main/res/layout/ucrop_activity_photobox.xml index 7434c4a4b..235e782c3 100644 --- a/ucrop/src/main/res/layout/ucrop_activity_photobox.xml +++ b/ucrop/src/main/res/layout/ucrop_activity_photobox.xml @@ -17,7 +17,7 @@ style="@style/TextAppearance.Widget.AppCompat.Toolbar.Title" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_gravity="center" + android:layout_gravity="start" android:text="@string/ucrop_label_edit_photo" android:textColor="@color/ucrop_color_toolbar_widget" /> @@ -26,10 +26,9 @@ + android:layout_height="wrap_content" + android:layout_above="@+id/controls_wrapper" + android:layout_below="@+id/toolbar"> + + diff --git a/ucrop/src/main/res/layout/ucrop_controls.xml b/ucrop/src/main/res/layout/ucrop_controls.xml index bf89576c3..451fcaf1a 100644 --- a/ucrop/src/main/res/layout/ucrop_controls.xml +++ b/ucrop/src/main/res/layout/ucrop_controls.xml @@ -1,78 +1,106 @@ - + + android:layout_alignParentTop="true" + android:layout_marginBottom="0dp"> + + + android:orientation="horizontal" /> + layout="@layout/ucrop_layout_rotate_wheel" /> + layout="@layout/ucrop_layout_scale_wheel" /> + android:layout_height="8dp" + android:layout_alignBottom="@+id/wrapper_controls" + android:src="@drawable/ucrop_shadow_upside" /> - + android:gravity="center" + android:orientation="vertical" + app:srcCompat="@drawable/ucrop_crop" /> - + - + + + app:srcCompat="@drawable/ucrop_rotate" /> - + - + + + app:srcCompat="@drawable/ucrop_scale" /> + + - + - + diff --git a/ucrop/src/main/res/layout/ucrop_fragment_photobox.xml b/ucrop/src/main/res/layout/ucrop_fragment_photobox.xml index ac529dc51..a2ff0467a 100644 --- a/ucrop/src/main/res/layout/ucrop_fragment_photobox.xml +++ b/ucrop/src/main/res/layout/ucrop_fragment_photobox.xml @@ -9,7 +9,7 @@ android:id="@+id/ucrop_frame" android:layout_width="match_parent" android:layout_height="match_parent" - android:layout_above="@+id/wrapper_controls" + android:layout_above="@+id/controls_wrapper" android:background="@color/ucrop_color_crop_background"> + + diff --git a/ucrop/src/main/res/layout/ucrop_layout_rotate_wheel.xml b/ucrop/src/main/res/layout/ucrop_layout_rotate_wheel.xml index b4877894c..6994701f3 100644 --- a/ucrop/src/main/res/layout/ucrop_layout_rotate_wheel.xml +++ b/ucrop/src/main/res/layout/ucrop_layout_rotate_wheel.xml @@ -1,26 +1,27 @@ + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:visibility="gone" + tools:showIn="@layout/ucrop_activity_photobox" + tools:visibility="visible"> + android:text="100°" /> + android:layout_toEndOf="@+id/wrapper_reset_rotate" + android:layout_toRightOf="@+id/wrapper_reset_rotate" /> + app:srcCompat="@drawable/ucrop_ic_reset" /> @@ -42,7 +43,7 @@ + android:src="@drawable/ucrop_ic_angle" /> diff --git a/ucrop/src/main/res/values/colors.xml b/ucrop/src/main/res/values/colors.xml index 3df81aebd..526e544af 100644 --- a/ucrop/src/main/res/values/colors.xml +++ b/ucrop/src/main/res/values/colors.xml @@ -2,14 +2,16 @@ - #FF6E40 - #CC5833 - #fff + #fff + #f5f5f5 + #000000 #000 - #FF6E40 - #fff + #FFFFFF + #FFFFFF + #512DA8 + #673AB7 #000 - #808080 + #000000 #000 diff --git a/ucrop/src/main/res/values/dimens.xml b/ucrop/src/main/res/values/dimens.xml index f7db77c7e..e7ef4e581 100644 --- a/ucrop/src/main/res/values/dimens.xml +++ b/ucrop/src/main/res/values/dimens.xml @@ -5,6 +5,7 @@ 8dp 20dp 2dp + 4dp 10dp 64dp 72dp diff --git a/ucrop/src/main/res/values/strings.xml b/ucrop/src/main/res/values/strings.xml index 5254f38aa..47594105c 100644 --- a/ucrop/src/main/res/values/strings.xml +++ b/ucrop/src/main/res/values/strings.xml @@ -7,5 +7,8 @@ Both input and output Uri must be specified Therefore, override color resource (ucrop_color_toolbar_widget) in your app to make it work on pre-L devices + Rotate + Scale + Crop diff --git a/ucrop/src/main/res/values/styles.xml b/ucrop/src/main/res/values/styles.xml index fbeb4c4ba..9eb4bdc88 100644 --- a/ucrop/src/main/res/values/styles.xml +++ b/ucrop/src/main/res/values/styles.xml @@ -15,6 +15,8 @@ 1 ?attr/selectableItemBackground true + center + vertical + +