• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

frameworks/base


Commit MetaInfo

Revisionb30338164bb2c0e69cd6421c8a165c16803ad423 (tree)
Time2020-06-11 21:16:55
Authorutzcoz <utzcoz@outl...>
Commiterutzcoz

Log Message

Add back button for freeform window

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

Change Summary

Incremental Difference

--- a/config/hiddenapi-private-dex.txt
+++ b/config/hiddenapi-private-dex.txt
@@ -113705,6 +113705,8 @@ Lcom/android/internal/R$drawable;->decor_close_button_dark:I
113705113705 Lcom/android/internal/R$drawable;->decor_close_button_light:I
113706113706 Lcom/android/internal/R$drawable;->decor_maximize_button_dark:I
113707113707 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
113708113710 Lcom/android/internal/R$drawable;->default_lock_wallpaper:I
113709113711 Lcom/android/internal/R$drawable;->default_wallpaper:I
113710113712 Lcom/android/internal/R$drawable;->dialog_frame:I
--- a/core/java/com/android/internal/policy/DecorView.java
+++ b/core/java/com/android/internal/policy/DecorView.java
@@ -1994,7 +1994,12 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
19941994 }
19951995
19961996 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(
19982003 R.drawable.decor_pip_button_light);
19992004 view.findViewById(R.id.minimize_window).setBackgroundResource(
20002005 R.drawable.decor_minimize_button_light);
@@ -2005,6 +2010,11 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
20052010 }
20062011
20072012 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
20082018 view.findViewById(R.id.pip_window).setBackgroundResource(
20092019 R.drawable.decor_pip_button_dark);
20102020 view.findViewById(R.id.minimize_window).setBackgroundResource(
--- a/core/java/com/android/internal/widget/DecorCaptionView.java
+++ b/core/java/com/android/internal/widget/DecorCaptionView.java
@@ -16,6 +16,7 @@
1616
1717 package com.android.internal.widget;
1818
19+import android.app.Activity;
1920 import android.content.Context;
2021 import android.graphics.Color;
2122 import android.graphics.Rect;
@@ -107,6 +108,10 @@ public class DecorCaptionView extends ViewGroup implements View.OnTouchListener,
107108 private final Rect mMinimizeRect = new Rect();
108109 private final Rect mPipRect = new Rect();
109110 private View mClickTarget;
111+ // region @boringdroid
112+ private View mBack;
113+ private final Rect mBackRect = new Rect();
114+ // endregion
110115
111116 public DecorCaptionView(Context context) {
112117 super(context);
@@ -147,6 +152,9 @@ public class DecorCaptionView extends ViewGroup implements View.OnTouchListener,
147152 // By changing the outline provider to BOUNDS, the window can remove its
148153 // background without removing the shadow.
149154 mOwner.getDecorView().setOutlineProvider(ViewOutlineProvider.BOUNDS);
155+ // region @boringdroid
156+ mBack = findViewById(R.id.back_window);
157+ // endregion
150158 mPip = findViewById(R.id.pip_window);
151159 mMinimize = findViewById(R.id.minimize_window);
152160 mMaximize = findViewById(R.id.maximize_window);
@@ -160,6 +168,11 @@ public class DecorCaptionView extends ViewGroup implements View.OnTouchListener,
160168 if (ev.getAction() == MotionEvent.ACTION_DOWN) {
161169 final int x = (int) ev.getX();
162170 final int y = (int) ev.getY();
171+ // region @boringdroid
172+ if (mBackRect.contains(x, y)) {
173+ mClickTarget = mBack;
174+ }
175+ // endregion
163176 // Only offset y for containment tests because the actual views are already translated.
164177 if (mPipRect.contains(x, y)) {
165178 mClickTarget = mPip;
@@ -311,12 +324,18 @@ public class DecorCaptionView extends ViewGroup implements View.OnTouchListener,
311324 if (mCaption.getVisibility() != View.GONE) {
312325 mCaption.layout(0, 0, mCaption.getMeasuredWidth(), mCaption.getMeasuredHeight());
313326 captionHeight = mCaption.getBottom() - mCaption.getTop();
327+ // region @boringdroid
328+ mBack.getHitRect(mBackRect);
329+ // endregion
314330 mPip.getHitRect(mPipRect);
315331 mMinimize.getHitRect(mMinimizeRect);
316332 mMaximize.getHitRect(mMaximizeRect);
317333 mClose.getHitRect(mCloseRect);
318334 } else {
319335 captionHeight = 0;
336+ // region @boringdroid
337+ mBackRect.setEmpty();
338+ // endregion
320339 mPipRect.setEmpty();
321340 mMinimizeRect.setEmpty();
322341 mMaximizeRect.setEmpty();
@@ -333,8 +352,12 @@ public class DecorCaptionView extends ViewGroup implements View.OnTouchListener,
333352 }
334353
335354 // 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(),
337359 mClose.getRight(), mClose.getBottom());
360+ // endregion
338361 }
339362 /**
340363 * Determine if the workspace is entirely covered by the window.
@@ -436,6 +459,16 @@ public class DecorCaptionView extends ViewGroup implements View.OnTouchListener,
436459
437460 @Override
438461 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
439472 if (mClickTarget == mMinimize) {
440473 minimizeWindow();
441474 } else if (mClickTarget == mPip) {
--- /dev/null
+++ b/core/res/res/drawable/decor_back_button_dark.xml
@@ -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+
--- /dev/null
+++ b/core/res/res/drawable/decor_back_button_light.xml
@@ -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>
--- a/core/res/res/layout/decor_caption.xml
+++ b/core/res/res/layout/decor_caption.xml
@@ -30,6 +30,22 @@
3030 android:background="@drawable/decor_caption_title"
3131 android:focusable="false"
3232 android:descendantFocusability="blocksDescendants" >
33+ <!-- region @boringdroid -->
34+ <Button
35+ android:id="@+id/back_window"
36+ android:layout_width="32dp"
37+ android:layout_height="32dp"
38+ android:layout_margin="5dp"
39+ android:padding="4dp"
40+ android:layout_gravity="center_vertical|start"
41+ android:contentDescription="@string/back_button_text"
42+ android:background="@drawable/decor_back_button_dark" />
43+ <Space
44+ android:layout_width="wrap_content"
45+ android:layout_height="wrap_content"
46+ android:layout_weight="1"
47+ android:background="@color/transparent" />
48+ <!-- endregion -->
3349 <Button
3450 android:id="@+id/pip_window"
3551 android:layout_width="32dp"
--- a/core/res/res/values/arrays.xml
+++ b/core/res/res/values/arrays.xml
@@ -143,6 +143,10 @@
143143 <item>@drawable/decor_minimize_button_light</item>
144144 <item>@drawable/decor_pip_button_dark</item>
145145 <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 -->
146150 </array>
147151
148152 <!-- Used in LocalePicker -->
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -4671,6 +4671,9 @@
46714671 <string name="floating_toolbar_close_overflow_description">Close overflow</string>
46724672
46734673 <!-- Free style window strings -->
4674+ <!-- region @boringdroid -->
4675+ <string name="back_button_text">Back</string>
4676+ <!-- endregion -->
46744677 <!-- Accessibility text for the minimize window button -->
46754678 <string name="pip_button_text">Picture In Picture</string>
46764679 <!-- Accessibility text for the minimize window button -->
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -2237,6 +2237,11 @@
22372237 <java-symbol type="drawable" name="decor_maximize_button_light" />
22382238 <java-symbol type="drawable" name="decor_pip_button_dark" />
22392239 <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 -->
22402245 <java-symbol type="color" name="decor_button_dark_color" />
22412246 <java-symbol type="color" name="decor_button_light_color" />
22422247