Skip to content

Commit

Permalink
Refactored and fixed code from PR.
Browse files Browse the repository at this point in the history
Added support for state drawables for old Android versions.
Updated version and README.md
  • Loading branch information
shliama committed Feb 17, 2016
1 parent 6587448 commit c9c4e8b
Show file tree
Hide file tree
Showing 21 changed files with 212 additions and 262 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Currently you can change:
* 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
* the UI colors (Toolbar, StatusBar, ActiveWidget and the RotationWheel line)
* the UI colors (Toolbar, StatusBar, active widget state)
* and more...
# Compatibility
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-beta4'
classpath 'com.android.tools.build:gradle:2.0.0-beta5'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
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=1.2.3
VERSION_CODE=9
VERSION_NAME=1.2.4
VERSION_CODE=10
GROUP=com.yalantis

POM_DESCRIPTION=Android Library for cropping images
Expand Down
19 changes: 6 additions & 13 deletions sample/src/main/java/com/yalantis/ucrop/sample/SampleActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.util.Log;
import android.view.View;
import android.widget.CheckBox;
Expand Down Expand Up @@ -216,18 +215,6 @@ private UCrop advancedConfig(@NonNull UCrop uCrop) {
}
options.setCompressionQuality(mSeekBarQuality.getProgress());

int TOOLBAR_COLOR = ContextCompat.getColor(this, R.color.toolbar);
int STATUS_BAR_COLOR = ContextCompat.getColor(this, R.color.status_bar);
int ACTIVE_WIDGET_COLOR = ContextCompat.getColor(this, R.color.active_widget);
int ROTATION_WHEEL_LINE_COLOR = ContextCompat.getColor(this, R.color.rotation_wheel_line);
int TEXT_COLOR_PRIMARY = ContextCompat.getColor(this, R.color.default_text_color);

options.setToolbarColor(TOOLBAR_COLOR);
options.setStatusBarColor(STATUS_BAR_COLOR);
options.setActiveWidgetColor(ACTIVE_WIDGET_COLOR);
options.setRotationWheelLineColor(ROTATION_WHEEL_LINE_COLOR);
options.setToolbarTitleTextColor(TEXT_COLOR_PRIMARY);

/*
If you want to configure how gestures work for all UCropActivity tabs
Expand Down Expand Up @@ -256,6 +243,12 @@ Tune everything (ノ◕ヮ◕)ノ*:・゚✧
options.setCropGridColumnCount(2);
options.setCropGridRowCount(1);
// Color palette
options.setToolbarColor(ContextCompat.getColor(this, R.color.your_color_res));
options.setStatusBarColor(ContextCompat.getColor(this, R.color.your_color_res));
options.setActiveWidgetColor(ContextCompat.getColor(this, R.color.your_color_res));
options.setToolbarTitleTextColor(ContextCompat.getColor(this, R.color.your_color_res));
*/

return uCrop.withOptions(options);
Expand Down
5 changes: 0 additions & 5 deletions sample/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,4 @@
<color name="colorPrimary">#FF6E40</color>
<color name="colorPrimaryDark">#CC5833</color>
<color name="colorAccent">#FF6E40</color>
<color name="toolbar">#FF6E40</color>
<color name="status_bar">#CC5833</color>
<color name="active_widget">#FF6E40</color>
<color name="rotation_wheel_line">#FF6E40</color>
<color name="default_text_color">#FFF</color>
</resources>
2 changes: 1 addition & 1 deletion ucrop/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ android {
defaultConfig {
minSdkVersion 10
targetSdkVersion 23
versionCode 9
versionCode 10
versionName "1.2.4"
}
buildTypes {
Expand Down
76 changes: 34 additions & 42 deletions ucrop/src/main/java/com/yalantis/ucrop/UCrop.java
Original file line number Diff line number Diff line change
Expand Up @@ -219,14 +219,13 @@ public static class Options {
public static final String EXTRA_CROP_GRID_COLUMN_COUNT = EXTRA_PREFIX + ".CropGridColumnCount";
public static final String EXTRA_CROP_GRID_COLOR = EXTRA_PREFIX + ".CropGridColor";
public static final String EXTRA_CROP_GRID_STROKE_WIDTH = EXTRA_PREFIX + ".CropGridStrokeWidth";

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_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_PROGRESS_WHEEL_LINE = EXTRA_PREFIX + ".UcropColorProgressWheelLine";

public static final String EXTRA_UCROP_TITLE_COLOR_TOOLBAR = EXTRA_PREFIX + ".UcropToolbarTitleColor";


public static final String EXTRA_UCROP_TITLE_COLOR_TOOLBAR = EXTRA_PREFIX + ".UcropToolbarTitleColor";


private final Bundle mOptionBundle;

Expand Down Expand Up @@ -358,42 +357,35 @@ public void setCropGridColor(@ColorInt int color) {
public void setCropGridStrokeWidth(@IntRange(from = 0) int width) {
mOptionBundle.putInt(EXTRA_CROP_GRID_STROKE_WIDTH, width);
}

/**
* @param color - desired resolved color of the toolbar
*/
public void setToolbarColor(@ColorInt int color){
mOptionBundle.putInt(EXTRA_TOOL_BAR_COLOR, color);
}

/**
* @param color - desired resolved color of the statusbar
*/
public void setStatusBarColor(@ColorInt int color){
mOptionBundle.putInt(EXTRA_STATUS_BAR_COLOR, color);
}

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

/**
* @param color - desired resolved color of the line in the rotation wheel (default is darker orange)
*/
public void setRotationWheelLineColor(@ColorInt int color){
mOptionBundle.putInt(EXTRA_UCROP_COLOR_PROGRESS_WHEEL_LINE, color);
}

/**
* @param color - desired resolved color of Toolbar text and buttons (default is darker orange)
*/
public void setToolbarTitleTextColor(@ColorInt int color){
mOptionBundle.putInt(EXTRA_UCROP_TITLE_COLOR_TOOLBAR, color);
}


/**
* @param color - desired resolved color of the toolbar
*/
public void setToolbarColor(@ColorInt int color) {
mOptionBundle.putInt(EXTRA_TOOL_BAR_COLOR, color);
}

/**
* @param color - desired resolved color of the statusbar
*/
public void setStatusBarColor(@ColorInt int color) {
mOptionBundle.putInt(EXTRA_STATUS_BAR_COLOR, color);
}

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

/**
* @param color - desired resolved color of Toolbar text and buttons (default is darker orange)
*/
public void setToolbarTitleTextColor(@ColorInt int color) {
mOptionBundle.putInt(EXTRA_UCROP_TITLE_COLOR_TOOLBAR, color);
}

}

}
Loading

0 comments on commit c9c4e8b

Please sign in to comment.