frameworks/base
Revision | b30338164bb2c0e69cd6421c8a165c16803ad423 (tree) |
---|---|
Time | 2020-06-11 21:16:55 |
Author | utzcoz <utzcoz@outl...> |
Commiter | utzcoz |
Add back button for freeform window
Signed-off-by: utzcoz <utzcoz@outlook.com>
@@ -113705,6 +113705,8 @@ Lcom/android/internal/R$drawable;->decor_close_button_dark:I | ||
113705 | 113705 | Lcom/android/internal/R$drawable;->decor_close_button_light:I |
113706 | 113706 | Lcom/android/internal/R$drawable;->decor_maximize_button_dark:I |
113707 | 113707 | Lcom/android/internal/R$drawable;->decor_maximize_button_light:I |
113708 | +Lcom/android/internal/R$drawable;->decor_back_button_dark:I | |
113709 | +Lcom/android/internal/R$drawable;->decor_back_button_light:I | |
113708 | 113710 | Lcom/android/internal/R$drawable;->default_lock_wallpaper:I |
113709 | 113711 | Lcom/android/internal/R$drawable;->default_wallpaper:I |
113710 | 113712 | Lcom/android/internal/R$drawable;->dialog_frame:I |
@@ -1994,7 +1994,12 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind | ||
1994 | 1994 | } |
1995 | 1995 | |
1996 | 1996 | private void setLightDecorCaptionShade(DecorCaptionView view) { |
1997 | - view.findViewById(R.id.pip_window).setBackgroundResource( | |
1997 | + // region @boringdroid | |
1998 | + view.findViewById(R.id.back_window).setBackgroundResource( | |
1999 | + R.drawable.decor_back_button_light | |
2000 | + ); | |
2001 | + // endregion | |
2002 | + view.findViewById(R.id.pip_window).setBackgroundResource( | |
1998 | 2003 | R.drawable.decor_pip_button_light); |
1999 | 2004 | view.findViewById(R.id.minimize_window).setBackgroundResource( |
2000 | 2005 | R.drawable.decor_minimize_button_light); |
@@ -2005,6 +2010,11 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind | ||
2005 | 2010 | } |
2006 | 2011 | |
2007 | 2012 | private void setDarkDecorCaptionShade(DecorCaptionView view) { |
2013 | + // region @boringdroid | |
2014 | + view.findViewById(R.id.back_window).setBackgroundResource( | |
2015 | + R.drawable.decor_back_button_dark | |
2016 | + ); | |
2017 | + // endregion | |
2008 | 2018 | view.findViewById(R.id.pip_window).setBackgroundResource( |
2009 | 2019 | R.drawable.decor_pip_button_dark); |
2010 | 2020 | view.findViewById(R.id.minimize_window).setBackgroundResource( |
@@ -16,6 +16,7 @@ | ||
16 | 16 | |
17 | 17 | package com.android.internal.widget; |
18 | 18 | |
19 | +import android.app.Activity; | |
19 | 20 | import android.content.Context; |
20 | 21 | import android.graphics.Color; |
21 | 22 | import android.graphics.Rect; |
@@ -107,6 +108,10 @@ public class DecorCaptionView extends ViewGroup implements View.OnTouchListener, | ||
107 | 108 | private final Rect mMinimizeRect = new Rect(); |
108 | 109 | private final Rect mPipRect = new Rect(); |
109 | 110 | private View mClickTarget; |
111 | + // region @boringdroid | |
112 | + private View mBack; | |
113 | + private final Rect mBackRect = new Rect(); | |
114 | + // endregion | |
110 | 115 | |
111 | 116 | public DecorCaptionView(Context context) { |
112 | 117 | super(context); |
@@ -147,6 +152,9 @@ public class DecorCaptionView extends ViewGroup implements View.OnTouchListener, | ||
147 | 152 | // By changing the outline provider to BOUNDS, the window can remove its |
148 | 153 | // background without removing the shadow. |
149 | 154 | mOwner.getDecorView().setOutlineProvider(ViewOutlineProvider.BOUNDS); |
155 | + // region @boringdroid | |
156 | + mBack = findViewById(R.id.back_window); | |
157 | + // endregion | |
150 | 158 | mPip = findViewById(R.id.pip_window); |
151 | 159 | mMinimize = findViewById(R.id.minimize_window); |
152 | 160 | mMaximize = findViewById(R.id.maximize_window); |
@@ -160,6 +168,11 @@ public class DecorCaptionView extends ViewGroup implements View.OnTouchListener, | ||
160 | 168 | if (ev.getAction() == MotionEvent.ACTION_DOWN) { |
161 | 169 | final int x = (int) ev.getX(); |
162 | 170 | final int y = (int) ev.getY(); |
171 | + // region @boringdroid | |
172 | + if (mBackRect.contains(x, y)) { | |
173 | + mClickTarget = mBack; | |
174 | + } | |
175 | + // endregion | |
163 | 176 | // Only offset y for containment tests because the actual views are already translated. |
164 | 177 | if (mPipRect.contains(x, y)) { |
165 | 178 | mClickTarget = mPip; |
@@ -311,12 +324,18 @@ public class DecorCaptionView extends ViewGroup implements View.OnTouchListener, | ||
311 | 324 | if (mCaption.getVisibility() != View.GONE) { |
312 | 325 | mCaption.layout(0, 0, mCaption.getMeasuredWidth(), mCaption.getMeasuredHeight()); |
313 | 326 | captionHeight = mCaption.getBottom() - mCaption.getTop(); |
327 | + // region @boringdroid | |
328 | + mBack.getHitRect(mBackRect); | |
329 | + // endregion | |
314 | 330 | mPip.getHitRect(mPipRect); |
315 | 331 | mMinimize.getHitRect(mMinimizeRect); |
316 | 332 | mMaximize.getHitRect(mMaximizeRect); |
317 | 333 | mClose.getHitRect(mCloseRect); |
318 | 334 | } else { |
319 | 335 | captionHeight = 0; |
336 | + // region @boringdroid | |
337 | + mBackRect.setEmpty(); | |
338 | + // endregion | |
320 | 339 | mPipRect.setEmpty(); |
321 | 340 | mMinimizeRect.setEmpty(); |
322 | 341 | mMaximizeRect.setEmpty(); |
@@ -333,8 +352,12 @@ public class DecorCaptionView extends ViewGroup implements View.OnTouchListener, | ||
333 | 352 | } |
334 | 353 | |
335 | 354 | // This assumes that the caption bar is at the top. |
336 | - mOwner.notifyRestrictedCaptionAreaCallback(mPip.getLeft(), mMaximize.getTop(), | |
355 | + // region @boringdroid | |
356 | + // mOwner.notifyRestrictedCaptionAreaCallback(mPip.getLeft(), mMaximize.getTop(), | |
357 | + // mClose.getRight(), mClose.getBottom()); | |
358 | + mOwner.notifyRestrictedCaptionAreaCallback(mBack.getLeft(), mBack.getTop(), | |
337 | 359 | mClose.getRight(), mClose.getBottom()); |
360 | + // endregion | |
338 | 361 | } |
339 | 362 | /** |
340 | 363 | * Determine if the workspace is entirely covered by the window. |
@@ -436,6 +459,16 @@ public class DecorCaptionView extends ViewGroup implements View.OnTouchListener, | ||
436 | 459 | |
437 | 460 | @Override |
438 | 461 | public boolean onSingleTapUp(MotionEvent e) { |
462 | + // region @boringdroid | |
463 | + if (mClickTarget == mBack) { | |
464 | + Window.WindowControllerCallback callback = mOwner.getWindowControllerCallback(); | |
465 | + if (callback instanceof Activity) { | |
466 | + Activity activity = (Activity) callback; | |
467 | + activity.onBackPressed(); | |
468 | + } | |
469 | + return true; | |
470 | + } | |
471 | + // endregion | |
439 | 472 | if (mClickTarget == mMinimize) { |
440 | 473 | minimizeWindow(); |
441 | 474 | } else if (mClickTarget == mPip) { |
@@ -0,0 +1,34 @@ | ||
1 | +<?xml version="1.0" encoding="utf-8"?> | |
2 | +<!-- Copyright (C) 2015 The Android Open Source Project | |
3 | + Copyright (C) 2020 boringdroid | |
4 | + | |
5 | + Licensed under the Apache License, Version 2.0 (the "License"); | |
6 | + you may not use this file except in compliance with the License. | |
7 | + You may obtain a copy of the License at | |
8 | + | |
9 | + http://www.apache.org/licenses/LICENSE-2.0 | |
10 | + | |
11 | + Unless required by applicable law or agreed to in writing, software | |
12 | + distributed under the License is distributed on an "AS IS" BASIS, | |
13 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
14 | + See the License for the specific language governing permissions and | |
15 | + limitations under the License. | |
16 | +--> | |
17 | + | |
18 | +<vector xmlns:android="http://schemas.android.com/apk/res/android" | |
19 | + android:width="32.0dp" | |
20 | + android:height="32.0dp" | |
21 | + android:viewportWidth="32.0" | |
22 | + android:viewportHeight="32.0" | |
23 | + android:tint="@color/decor_button_dark_color"> | |
24 | + <group android:scaleX="0.5" | |
25 | + android:scaleY="0.5" | |
26 | + android:translateX="8.0" | |
27 | + android:translateY="8.0"> | |
28 | + <path | |
29 | + android:fillColor="@color/white" | |
30 | + android:pathData="M2.0,16.0l28.0,14.0l0.0,-28z" /> | |
31 | + </group> | |
32 | +</vector> | |
33 | + | |
34 | + |
@@ -0,0 +1,31 @@ | ||
1 | +<!-- Copyright (C) 2015 The Android Open Source Project | |
2 | + Copyright (C) boringdroid | |
3 | + | |
4 | + Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | + you may not use this file except in compliance with the License. | |
6 | + You may obtain a copy of the License at | |
7 | + | |
8 | + http://www.apache.org/licenses/LICENSE-2.0 | |
9 | + | |
10 | + Unless required by applicable law or agreed to in writing, software | |
11 | + distributed under the License is distributed on an "AS IS" BASIS, | |
12 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | + See the License for the specific language governing permissions and | |
14 | + limitations under the License. | |
15 | +--> | |
16 | + | |
17 | +<vector xmlns:android="http://schemas.android.com/apk/res/android" | |
18 | + android:width="32.0dp" | |
19 | + android:height="32.0dp" | |
20 | + android:viewportWidth="32.0" | |
21 | + android:viewportHeight="32.0" | |
22 | + android:tint="@color/decor_button_light_color"> | |
23 | + <group android:scaleX="0.5" | |
24 | + android:scaleY="0.5" | |
25 | + android:translateX="8.0" | |
26 | + android:translateY="8.0"> | |
27 | + <path | |
28 | + android:fillColor="@color/white" | |
29 | + android:pathData="M2.0,16.0l28.0,14.0l0.0,-28z" /> | |
30 | + </group> | |
31 | +</vector> |
@@ -143,6 +143,10 @@ | ||
143 | 143 | <item>@drawable/decor_minimize_button_light</item> |
144 | 144 | <item>@drawable/decor_pip_button_dark</item> |
145 | 145 | <item>@drawable/decor_pip_button_light</item> |
146 | + <!-- region @boringdroid --> | |
147 | + <item>@drawable/decor_back_button_dark</item> | |
148 | + <item>@drawable/decor_back_button_light</item> | |
149 | + <!-- endregion --> | |
146 | 150 | </array> |
147 | 151 | |
148 | 152 | <!-- Used in LocalePicker --> |
@@ -4671,6 +4671,9 @@ | ||
4671 | 4671 | <string name="floating_toolbar_close_overflow_description">Close overflow</string> |
4672 | 4672 | |
4673 | 4673 | <!-- Free style window strings --> |
4674 | + <!-- region @boringdroid --> | |
4675 | + <string name="back_button_text">Back</string> | |
4676 | + <!-- endregion --> | |
4674 | 4677 | <!-- Accessibility text for the minimize window button --> |
4675 | 4678 | <string name="pip_button_text">Picture In Picture</string> |
4676 | 4679 | <!-- Accessibility text for the minimize window button --> |
@@ -2237,6 +2237,11 @@ | ||
2237 | 2237 | <java-symbol type="drawable" name="decor_maximize_button_light" /> |
2238 | 2238 | <java-symbol type="drawable" name="decor_pip_button_dark" /> |
2239 | 2239 | <java-symbol type="drawable" name="decor_pip_button_light" /> |
2240 | + <!-- region @boringdroid --> | |
2241 | + <java-symbol type="id" name="back_window" /> | |
2242 | + <java-symbol type="drawable" name="decor_back_button_dark" /> | |
2243 | + <java-symbol type="drawable" name="decor_back_button_light" /> | |
2244 | + <!-- endregion --> | |
2240 | 2245 | <java-symbol type="color" name="decor_button_dark_color" /> |
2241 | 2246 | <java-symbol type="color" name="decor_button_light_color" /> |
2242 | 2247 |