diff --git a/lib/src/main/java/com/auth0/android/lock/views/SocialButton.java b/lib/src/main/java/com/auth0/android/lock/views/SocialButton.java index b10d2d296..2a7e6831c 100644 --- a/lib/src/main/java/com/auth0/android/lock/views/SocialButton.java +++ b/lib/src/main/java/com/auth0/android/lock/views/SocialButton.java @@ -50,13 +50,13 @@ public void onFocusChange(View v, boolean hasFocus) { } private StateListDrawable getTouchFeedbackBackground(@ColorInt int pressedColor, @ViewUtils.Corners int corners) { - final ShapeDrawable normalBackground; + final Drawable normalBackground; final ShapeDrawable pressedBackground; boolean shouldDrawOutline = pressedColor == Color.WHITE; if (shouldDrawOutline) { int outlineColor = getResources().getColor(R.color.com_auth0_lock_social_light_background_focused); - normalBackground = ViewUtils.getRoundedOutlineBackground(getResources(), outlineColor); + normalBackground = ViewUtils.getOpaqueRoundedOutlineBackground(getResources(), pressedColor, outlineColor); pressedBackground = ViewUtils.getRoundedBackground(this, outlineColor, corners); } else { normalBackground = ViewUtils.getRoundedBackground(this, pressedColor, corners); diff --git a/lib/src/main/java/com/auth0/android/lock/views/ViewUtils.java b/lib/src/main/java/com/auth0/android/lock/views/ViewUtils.java index 4ab406ee4..d86be78ac 100644 --- a/lib/src/main/java/com/auth0/android/lock/views/ViewUtils.java +++ b/lib/src/main/java/com/auth0/android/lock/views/ViewUtils.java @@ -28,6 +28,7 @@ import android.content.res.Resources; import android.graphics.RectF; import android.graphics.drawable.Drawable; +import android.graphics.drawable.GradientDrawable; import android.graphics.drawable.ShapeDrawable; import android.graphics.drawable.shapes.RoundRectShape; import android.os.Build; @@ -113,10 +114,10 @@ static ShapeDrawable getRoundedBackground(@NonNull View view, @ColorInt int colo } /** - * Generates a rounded outline drawable with the given background color. + * Generates a rounded outline drawable with a transparent background. * * @param resources the context's current resources. - * @param color the color to use as background. + * @param color the color to use for the outline. * @return the rounded drawable. */ static ShapeDrawable getRoundedOutlineBackground(Resources resources, @ColorInt int color) { @@ -128,6 +129,28 @@ static ShapeDrawable getRoundedOutlineBackground(Resources resources, @ColorInt return drawable; } + /** + * Generates a rounded outline drawable with the given background color. + * + * @param resources the context's current resources. + * @param backgroundColor the color to use for the background. + * @param outlineColor the color to use for the outline + * @return the opaque rounded drawable. + */ + static Drawable getOpaqueRoundedOutlineBackground( + Resources resources, + @ColorInt int backgroundColor, + @ColorInt int outlineColor + ) { + int cornerRadius = resources.getDimensionPixelSize(R.dimen.com_auth0_lock_widget_corner_radius); + int stroke = resources.getDimensionPixelSize(R.dimen.com_auth0_lock_input_field_stroke_width); + GradientDrawable drawable = new GradientDrawable(); + drawable.setCornerRadius(cornerRadius); + drawable.setColor(backgroundColor); + drawable.setStroke(stroke, outlineColor); + return drawable; + } + /** * Sets a background drawable to a view, safely using the latest available sdk method. *