Skip to content

Commit

Permalink
advance niggerty.
Browse files Browse the repository at this point in the history
  • Loading branch information
sanmiAde committed Apr 27, 2020
1 parent b6315c6 commit 7a83975
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 25 deletions.
42 changes: 26 additions & 16 deletions ucrop/src/main/java/com/yalantis/ucrop/UCropActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,8 @@ private void initiateRootViews() {
private TransformImageView.TransformImageListener mImageListener = new TransformImageView.TransformImageListener() {
@Override
public void onRotate(float currentAngle) {
setAngleText(currentAngle);
//setAngleText(currentAngle);

}

@Override
Expand Down Expand Up @@ -490,7 +491,13 @@ private void setupRotateWidget() {
.setScrollingListener(new HorizontalProgressWheelView.ScrollingListener() {
@Override
public void onScroll(float delta, float totalDistance) {
mGestureCropImageView.postRotate(delta / ROTATE_WIDGET_SENSITIVITY_COEFFICIENT);
if (delta > 0) {
mGestureCropImageView.zoomInImage(mGestureCropImageView.getCurrentScale()
+ delta * ((mGestureCropImageView.getMaxScale() - mGestureCropImageView.getMinScale()) / SCALE_WIDGET_SENSITIVITY_COEFFICIENT));
} else {
mGestureCropImageView.zoomOutImage(mGestureCropImageView.getCurrentScale()
+ delta * ((mGestureCropImageView.getMaxScale() - mGestureCropImageView.getMinScale()) / SCALE_WIDGET_SENSITIVITY_COEFFICIENT));
}
}

@Override
Expand All @@ -506,6 +513,7 @@ public void onScrollStart() {

((HorizontalProgressWheelView) findViewById(R.id.rotate_scroll_wheel)).setMiddleLineColor(mActiveControlsWidgetColor);

setScaleTextColor(mActiveControlsWidgetColor);

findViewById(R.id.wrapper_reset_rotate).setOnClickListener(new View.OnClickListener() {
@Override
Expand Down Expand Up @@ -565,14 +573,14 @@ private void setAngleTextColor(int textColor) {
}

private void setScaleText(float scale) {
if (mTextViewScalePercent != null) {
mTextViewScalePercent.setText(String.format(Locale.getDefault(), "%d%%", (int) (scale * 100)));
if ( mTextViewRotateAngle != null) {
mTextViewRotateAngle.setText(String.format(Locale.getDefault(), "%d%%", (int) (scale * 100)));
}
}

private void setScaleTextColor(int textColor) {
if (mTextViewScalePercent != null) {
mTextViewScalePercent.setTextColor(textColor);
if ( mTextViewRotateAngle != null) {
mTextViewRotateAngle.setTextColor(textColor);
}
}

Expand All @@ -596,15 +604,17 @@ public void onClick(View v) {
};

private void setInitialState() {
if (mShowBottomControls) {
if (mWrapperStateAspectRatio.getVisibility() == View.VISIBLE) {
setWidgetState(R.id.state_aspect_ratio);
} else {
setWidgetState(R.id.state_scale);
}
} else {
setAllowedGestures(0);
}
setWidgetState(R.id.state_rotate);
// if (mShowBottomControls) {
//
// if (mWrapperStateAspectRatio.getVisibility() == View.VISIBLE) {
// setWidgetState(R.id.state_aspect_ratio);
// } else {
// setWidgetState(R.id.state_rotate);
// }
// } else {
// setAllowedGestures(0);
// }
}

private void setWidgetState(@IdRes int stateViewId) {
Expand All @@ -623,7 +633,7 @@ private void setWidgetState(@IdRes int stateViewId) {
if (stateViewId == R.id.state_scale) {
setAllowedGestures(0);
} else if (stateViewId == R.id.state_rotate) {
setAllowedGestures(1);
setAllowedGestures(0);
} else {
setAllowedGestures(2);
}
Expand Down
9 changes: 5 additions & 4 deletions ucrop/src/main/java/com/yalantis/ucrop/UCropFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,8 @@ private void initiateRootViews(View view) {
private TransformImageView.TransformImageListener mImageListener = new TransformImageView.TransformImageListener() {
@Override
public void onRotate(float currentAngle) {
setAngleText(currentAngle);
//setAngleText(currentAngle);

}

@Override
Expand Down Expand Up @@ -448,8 +449,8 @@ private void setAngleTextColor(int textColor) {
}

private void setScaleText(float scale) {
if (mTextViewScalePercent != null) {
mTextViewScalePercent.setText(String.format(Locale.getDefault(), "%d%%", (int) (scale * 100)));
if (mTextViewRotateAngle != null) {
mTextViewRotateAngle.setText(String.format(Locale.getDefault(), "%d%%", (int) (scale * 100)));
}
}

Expand Down Expand Up @@ -516,7 +517,7 @@ 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);
mWrapperStateScale.findViewById(R.id.text_view_scale).setVisibility(stateViewId == R.id.state_rotate ? 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);
}
Expand Down
2 changes: 1 addition & 1 deletion ucrop/src/main/res/layout/ucrop_activity_photobox.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
style="@style/TextAppearance.Widget.AppCompat.Toolbar.Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:layout_gravity="center_horizontal|center_vertical"
android:text="@string/ucrop_label_edit_photo"
android:textColor="@color/ucrop_color_toolbar_widget" />

Expand Down
6 changes: 4 additions & 2 deletions ucrop/src/main/res/layout/ucrop_controls.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@

<include
android:id="@+id/layout_scale_wheel"
layout="@layout/ucrop_layout_scale_wheel" />
layout="@layout/ucrop_layout_scale_wheel"
android:visibility="gone" />

</FrameLayout>

Expand All @@ -49,7 +50,8 @@
android:background="@color/ucrop_color_widget_background"
android:baselineAligned="false"
android:gravity="center"
android:orientation="horizontal">
android:orientation="horizontal"
android:visibility="gone">

<LinearLayout
android:id="@+id/state_aspect_ratio"
Expand Down
2 changes: 1 addition & 1 deletion ucrop/src/main/res/layout/ucrop_layout_rotate_wheel.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<com.yalantis.ucrop.view.widget.HorizontalProgressWheelView
android:id="@+id/rotate_scroll_wheel"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/text_view_rotate"
android:layout_toStartOf="@+id/wrapper_rotate_by_angle"
android:layout_toLeftOf="@+id/wrapper_rotate_by_angle"
Expand Down
2 changes: 1 addition & 1 deletion ucrop/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<dimen name="ucrop_width_horizontal_wheel_progress_line">2dp</dimen>
<dimen name="ucrop_width_middle_wheel_progress_line">4dp</dimen>
<dimen name="ucrop_margin_horizontal_wheel_progress_line">10dp</dimen>
<dimen name="ucrop_height_wrapper_controls">64dp</dimen>
<dimen name="ucrop_height_wrapper_controls">130dp</dimen>
<dimen name="ucrop_height_wrapper_states">72dp</dimen>
<dimen name="ucrop_height_divider_shadow">3dp</dimen>
<dimen name="ucrop_text_size_widget_text">13sp</dimen>
Expand Down

0 comments on commit 7a83975

Please sign in to comment.