diff --git a/twidere/src/main/java/org/mariotaku/twidere/view/CircularImageView.java b/twidere/src/main/java/org/mariotaku/twidere/view/CircularImageView.java index b4d081e67..833a15577 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/view/CircularImageView.java +++ b/twidere/src/main/java/org/mariotaku/twidere/view/CircularImageView.java @@ -29,6 +29,7 @@ import android.graphics.Canvas; import android.graphics.Color; import android.graphics.ColorFilter; import android.graphics.Matrix; +import android.graphics.Matrix.ScaleToFit; import android.graphics.Outline; import android.graphics.Paint; import android.graphics.PorterDuff.Mode; @@ -313,8 +314,36 @@ public class CircularImageView extends ImageView { Shader.TileMode.CLAMP); mMatrix.reset(); + switch (getScaleType()) { + case CENTER_CROP: { + final float srcRatio = source.width() / source.height(); + final float dstRatio = dest.width() / dest.height(); + if (srcRatio > dstRatio) { + // Source is wider than destination, fit height + tempDest.top = dest.top; + tempDest.bottom = dest.bottom; + final float dstWidth = dest.height() * srcRatio; + tempDest.left = dest.centerX() - dstWidth / 2; + tempDest.right = dest.centerX() + dstWidth / 2; + } else if (srcRatio < dstRatio) { + tempDest.left = dest.left; + tempDest.right = dest.right; + final float dstHeight = dest.width() / srcRatio; + tempDest.top = dest.centerY() - dstHeight / 2; + tempDest.bottom = dest.centerY() + dstHeight / 2; + } else { + tempDest.set(dest); + } + break; + } + default: { + tempDest.set(dest); + break; + } + } + // Fit bitmap to bounds. - mMatrix.setRectToRect(source, dest, Matrix.ScaleToFit.FILL); + mMatrix.setRectToRect(source, tempDest, ScaleToFit.CENTER); shader.setLocalMatrix(mMatrix); mBitmapPaint.setShader(shader); @@ -323,6 +352,8 @@ public class CircularImageView extends ImageView { } + private RectF tempDest = new RectF(); + @TargetApi(Build.VERSION_CODES.LOLLIPOP) private static class CircularOutlineProvider extends ViewOutlineProvider { @Override diff --git a/twidere/src/main/res/drawable/divider_horizontal_small_holo.xml b/twidere/src/main/res/drawable/divider_horizontal_small_holo.xml deleted file mode 100644 index e345985e2..000000000 --- a/twidere/src/main/res/drawable/divider_horizontal_small_holo.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/twidere/src/main/res/drawable/divider_vertical_small_holo.xml b/twidere/src/main/res/drawable/divider_vertical_small_holo.xml deleted file mode 100644 index a8c5090bf..000000000 --- a/twidere/src/main/res/drawable/divider_vertical_small_holo.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/twidere/src/main/res/drawable/ic_assist_twidere.xml b/twidere/src/main/res/drawable/ic_assist_twidere.xml index 3b03453ad..5cb1faf99 100644 --- a/twidere/src/main/res/drawable/ic_assist_twidere.xml +++ b/twidere/src/main/res/drawable/ic_assist_twidere.xml @@ -16,8 +16,17 @@ --> - - - + + + \ No newline at end of file diff --git a/twidere/src/main/res/layout/header_user.xml b/twidere/src/main/res/layout/header_user.xml index e8d4d7904..04b5b916d 100644 --- a/twidere/src/main/res/layout/header_user.xml +++ b/twidere/src/main/res/layout/header_user.xml @@ -233,7 +233,7 @@ android:layout_width="match_parent" android:layout_height="@dimen/action_button_size" android:baselineAligned="false" - android:divider="@drawable/divider_vertical_small_holo" + android:divider="?android:dividerHorizontal" android:orientation="horizontal" android:showDividers="middle" android:splitMotionEvents="false"> diff --git a/twidere/src/main/res/values-v21/styles.xml b/twidere/src/main/res/values-v21/styles.xml index fabe3920f..eb08eb89f 100644 --- a/twidere/src/main/res/values-v21/styles.xml +++ b/twidere/src/main/res/values-v21/styles.xml @@ -22,6 +22,7 @@ diff --git a/twidere/src/main/res/values/styles.xml b/twidere/src/main/res/values/styles.xml index 74066850b..f01ba2e7e 100644 --- a/twidere/src/main/res/values/styles.xml +++ b/twidere/src/main/res/values/styles.xml @@ -144,5 +144,6 @@ \ No newline at end of file