Android-x86
Fork
Donation

  • R/O
  • HTTP
  • SSH
  • HTTPS

frameworks-base: Commit

frameworks/base


Commit MetaInfo

Revision298304e0b42263e540bcf02951b24574843a3064 (tree)
Time2020-07-23 22:21:01
Authorutzcoz <utzcoz@outl...>
Commiterutzcoz

Log Message

Impl basic window round corner with Outline

Signed-off-by: utzcoz <utzcoz@outlook.com>

Change Summary

Incremental Difference

--- a/core/java/com/android/internal/policy/DecorView.java
+++ b/core/java/com/android/internal/policy/DecorView.java
@@ -250,6 +250,15 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
250250 private final Paint mVerticalResizeShadowPaint = new Paint();
251251 private final Paint mHorizontalResizeShadowPaint = new Paint();
252252
253+ // region @boringdroid
254+ private float mWindowCornerRadius = 8;
255+ private ViewOutlineProvider mWindowOutline = new ViewOutlineProvider() {
256+ @Override
257+ public void getOutline(View view, Outline outline) {
258+ outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), mWindowCornerRadius);
259+ }
260+ };
261+ // endregion
253262 DecorView(Context context, int featureId, PhoneWindow window,
254263 WindowManager.LayoutParams params) {
255264 super(context);
@@ -277,6 +286,9 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
277286 mResizeShadowSize = context.getResources().getDimensionPixelSize(
278287 R.dimen.resize_shadow_size);
279288 initResizingPaints();
289+ // region @boringdroid
290+ mWindowCornerRadius = context.getResources().getDimension(R.dimen.decor_corner_radius);
291+ // endregion
280292 }
281293
282294 void setBackgroundFallback(int resId) {
@@ -1853,6 +1865,9 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
18531865 // Configuration now requires a caption.
18541866 final LayoutInflater inflater = mWindow.getLayoutInflater();
18551867 mDecorCaptionView = createDecorCaptionView(inflater);
1868+ // region @boringdroid
1869+ updateWindowCorner();
1870+ // endregion
18561871 if (mDecorCaptionView != null) {
18571872 if (mDecorCaptionView.getParent() == null) {
18581873 addView(mDecorCaptionView, 0,
@@ -1882,6 +1897,9 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
18821897 }
18831898
18841899 mDecorCaptionView = createDecorCaptionView(inflater);
1900+ // region @boringdroid
1901+ updateWindowCorner();
1902+ // endregion
18851903 final View root = inflater.inflate(layoutResource, null);
18861904 if (mDecorCaptionView != null) {
18871905 if (mDecorCaptionView.getParent() == null) {
@@ -1987,6 +2005,17 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
19872005 }
19882006 }
19892007
2008+ // region @boringdroid
2009+ private void updateWindowCorner() {
2010+ if (mDecorCaptionView == null) {
2011+ setClipToOutline(false);
2012+ setOutlineProvider(null);
2013+ } else {
2014+ setOutlineProvider(mWindowOutline);
2015+ setClipToOutline(true);
2016+ }
2017+ }
2018+ // endregion
19902019 void updateDecorCaptionShade() {
19912020 if (mDecorCaptionView != null) {
19922021 setDecorCaptionShade(getContext(), mDecorCaptionView);
--- a/core/res/res/values/dimens.xml
+++ b/core/res/res/values/dimens.xml
@@ -694,4 +694,7 @@
694694 <dimen name="harmful_app_message_padding_bottom">24dp</dimen>
695695 <!-- Line spacing modifier for the message field of the harmful app dialog -->
696696 <item name="harmful_app_message_line_spacing_modifier" type="dimen">1.22</item>
697+ <!-- region @boringdroid -->
698+ <item name="decor_corner_radius" type="dimen">8dp</item>
699+ <!-- endregion -->
697700 </resources>
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -2241,6 +2241,7 @@
22412241 <java-symbol type="id" name="back_window" />
22422242 <java-symbol type="drawable" name="decor_back_button_dark" />
22432243 <java-symbol type="drawable" name="decor_back_button_light" />
2244+ <java-symbol type="dimen" name="decor_corner_radius" />
22442245 <!-- endregion -->
22452246 <java-symbol type="color" name="decor_button_dark_color" />
22462247 <java-symbol type="color" name="decor_button_light_color" />
Show on old repository browser