frameworks/base
Revision | 298304e0b42263e540bcf02951b24574843a3064 (tree) |
---|---|
Time | 2020-07-23 22:21:01 |
Author | utzcoz <utzcoz@outl...> |
Commiter | utzcoz |
Impl basic window round corner with Outline
Signed-off-by: utzcoz <utzcoz@outlook.com>
@@ -250,6 +250,15 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind | ||
250 | 250 | private final Paint mVerticalResizeShadowPaint = new Paint(); |
251 | 251 | private final Paint mHorizontalResizeShadowPaint = new Paint(); |
252 | 252 | |
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 | |
253 | 262 | DecorView(Context context, int featureId, PhoneWindow window, |
254 | 263 | WindowManager.LayoutParams params) { |
255 | 264 | super(context); |
@@ -277,6 +286,9 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind | ||
277 | 286 | mResizeShadowSize = context.getResources().getDimensionPixelSize( |
278 | 287 | R.dimen.resize_shadow_size); |
279 | 288 | initResizingPaints(); |
289 | + // region @boringdroid | |
290 | + mWindowCornerRadius = context.getResources().getDimension(R.dimen.decor_corner_radius); | |
291 | + // endregion | |
280 | 292 | } |
281 | 293 | |
282 | 294 | void setBackgroundFallback(int resId) { |
@@ -1853,6 +1865,9 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind | ||
1853 | 1865 | // Configuration now requires a caption. |
1854 | 1866 | final LayoutInflater inflater = mWindow.getLayoutInflater(); |
1855 | 1867 | mDecorCaptionView = createDecorCaptionView(inflater); |
1868 | + // region @boringdroid | |
1869 | + updateWindowCorner(); | |
1870 | + // endregion | |
1856 | 1871 | if (mDecorCaptionView != null) { |
1857 | 1872 | if (mDecorCaptionView.getParent() == null) { |
1858 | 1873 | addView(mDecorCaptionView, 0, |
@@ -1882,6 +1897,9 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind | ||
1882 | 1897 | } |
1883 | 1898 | |
1884 | 1899 | mDecorCaptionView = createDecorCaptionView(inflater); |
1900 | + // region @boringdroid | |
1901 | + updateWindowCorner(); | |
1902 | + // endregion | |
1885 | 1903 | final View root = inflater.inflate(layoutResource, null); |
1886 | 1904 | if (mDecorCaptionView != null) { |
1887 | 1905 | if (mDecorCaptionView.getParent() == null) { |
@@ -1987,6 +2005,17 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind | ||
1987 | 2005 | } |
1988 | 2006 | } |
1989 | 2007 | |
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 | |
1990 | 2019 | void updateDecorCaptionShade() { |
1991 | 2020 | if (mDecorCaptionView != null) { |
1992 | 2021 | setDecorCaptionShade(getContext(), mDecorCaptionView); |
@@ -694,4 +694,7 @@ | ||
694 | 694 | <dimen name="harmful_app_message_padding_bottom">24dp</dimen> |
695 | 695 | <!-- Line spacing modifier for the message field of the harmful app dialog --> |
696 | 696 | <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 --> | |
697 | 700 | </resources> |
@@ -2241,6 +2241,7 @@ | ||
2241 | 2241 | <java-symbol type="id" name="back_window" /> |
2242 | 2242 | <java-symbol type="drawable" name="decor_back_button_dark" /> |
2243 | 2243 | <java-symbol type="drawable" name="decor_back_button_light" /> |
2244 | + <java-symbol type="dimen" name="decor_corner_radius" /> | |
2244 | 2245 | <!-- endregion --> |
2245 | 2246 | <java-symbol type="color" name="decor_button_dark_color" /> |
2246 | 2247 | <java-symbol type="color" name="decor_button_light_color" /> |