Update the resize frame to use the forced radius.

When forcing the rounded corners, the radius may be smaller than the
default one. When this happens, we should change how the frame is drawn
to only use that reduced radius, or this looks weird.

Bug: 183097166
Test: Manual tests with top 1P App Widgets
Change-Id: I6ce232515ce14059e1168e16735719ea2370132c
This commit is contained in:
Pierre Barbier de Reuille
2021-03-19 23:16:54 +00:00
parent 298526e812
commit 452df2d5bb
3 changed files with 14 additions and 0 deletions

View File

@@ -14,12 +14,15 @@ import android.appwidget.AppWidgetProviderInfo;
import android.content.Context;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.os.Bundle;
import android.util.AttributeSet;
import android.util.SizeF;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageView;
import androidx.annotation.Nullable;
@@ -166,6 +169,15 @@ public class AppWidgetResizeFrame extends AbstractFloatingView implements View.O
DragLayer dl = launcher.getDragLayer();
AppWidgetResizeFrame frame = (AppWidgetResizeFrame) launcher.getLayoutInflater()
.inflate(R.layout.app_widget_resize_frame, dl, false);
if (widget.hasEnforcedCornerRadius()) {
float enforcedCornerRadius = widget.getEnforcedCornerRadius();
ImageView imageView = frame.findViewById(R.id.widget_resize_frame);
Drawable d = imageView.getDrawable();
if (d instanceof GradientDrawable) {
GradientDrawable gd = (GradientDrawable) d.mutate();
gd.setCornerRadius(enforcedCornerRadius);
}
}
frame.setupForWidget(widget, cellLayout, dl);
((DragLayer.LayoutParams) frame.getLayoutParams()).customPosition = true;