Merge "[DO NOT MERGE] Add placeholder for info panel in new power menu" into sc-dev

This commit is contained in:
Beth Thibodeau
2021-05-27 22:16:34 +00:00
committed by Android (Google) Code Review
10 changed files with 164 additions and 8 deletions

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2021 The Android Open Source Project
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<ImageView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/global_actions_change_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>

View File

@@ -13,13 +13,12 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
--> -->
<LinearLayout <androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/global_actions_container" android:id="@+id/global_actions_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center" android:gravity="center"
android:layout_gravity="center"> android:layout_gravity="center">
<com.android.systemui.globalactions.GlobalActionsLayoutLite <com.android.systemui.globalactions.GlobalActionsLayoutLite
@@ -29,8 +28,11 @@
android:orientation="vertical" android:orientation="vertical"
android:clipChildren="false" android:clipChildren="false"
android:clipToPadding="false" android:clipToPadding="false"
android:background="@drawable/global_actions_lite_background" app:layout_constraintBottom_toBottomOf="parent"
android:padding="@dimen/global_actions_lite_padding"> app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_weight="1">
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@@ -38,6 +40,8 @@
android:gravity="center" android:gravity="center"
android:translationZ="@dimen/global_actions_translate" android:translationZ="@dimen/global_actions_translate"
android:orientation="horizontal" android:orientation="horizontal"
android:background="@drawable/global_actions_lite_background"
android:padding="@dimen/global_actions_lite_padding"
android:layoutDirection="ltr"> android:layoutDirection="ltr">
<androidx.constraintlayout.helper.widget.Flow <androidx.constraintlayout.helper.widget.Flow
android:id="@+id/list_flow" android:id="@+id/list_flow"
@@ -53,4 +57,4 @@
app:flow_horizontalStyle="packed"/> app:flow_horizontalStyle="packed"/>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</com.android.systemui.globalactions.GlobalActionsLayoutLite> </com.android.systemui.globalactions.GlobalActionsLayoutLite>
</LinearLayout> </androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -603,6 +603,8 @@
<!-- Whether wallet view is shown in landscape / seascape orientations --> <!-- Whether wallet view is shown in landscape / seascape orientations -->
<bool name="global_actions_show_landscape_wallet_view">false</bool> <bool name="global_actions_show_landscape_wallet_view">false</bool>
<!-- Whether global actions should show an informational message about changes in S -->
<bool name="global_actions_show_change_info">false</bool>
<!-- Package name of the preferred system app to perform eSOS action --> <!-- Package name of the preferred system app to perform eSOS action -->
<string name="config_preferredEmergencySosPackage" translatable="false"></string> <string name="config_preferredEmergencySosPackage" translatable="false"></string>

View File

@@ -1106,6 +1106,7 @@
<dimen name="global_actions_button_padding">38dp</dimen> <dimen name="global_actions_button_padding">38dp</dimen>
<dimen name="global_actions_corner_radius">28dp</dimen> <dimen name="global_actions_corner_radius">28dp</dimen>
<dimen name="global_actions_lite_padding">24dp</dimen> <dimen name="global_actions_lite_padding">24dp</dimen>
<dimen name="global_actions_info_margin">32dp</dimen>
<!-- The maximum offset in either direction that elements are moved horizontally to prevent <!-- The maximum offset in either direction that elements are moved horizontally to prevent
burn-in on AOD. --> burn-in on AOD. -->

View File

@@ -2966,4 +2966,7 @@
<!-- Content description for a chip in the status bar showing that the user is currently on a phone call. [CHAR LIMIT=NONE] --> <!-- Content description for a chip in the status bar showing that the user is currently on a phone call. [CHAR LIMIT=NONE] -->
<string name="ongoing_phone_call_content_description">Ongoing phone call</string> <string name="ongoing_phone_call_content_description">Ongoing phone call</string>
<!-- URL for more information about changes in global actions -->
<string name="global_actions_change_url" translatable="false"></string>
</resources> </resources>

View File

@@ -151,6 +151,7 @@ public class GlobalActionsDialog extends GlobalActionsDialogLite
iWindowManager, iWindowManager,
backgroundExecutor, backgroundExecutor,
uiEventLogger, uiEventLogger,
null,
ringerModeTracker, sysUiState, handler); ringerModeTracker, sysUiState, handler);
mLockPatternUtils = lockPatternUtils; mLockPatternUtils = lockPatternUtils;
@@ -298,7 +299,7 @@ public class GlobalActionsDialog extends GlobalActionsDialogLite
super(context, com.android.systemui.R.style.Theme_SystemUI_Dialog_GlobalActions, super(context, com.android.systemui.R.style.Theme_SystemUI_Dialog_GlobalActions,
adapter, overflowAdapter, depthController, sysuiColorExtractor, adapter, overflowAdapter, depthController, sysuiColorExtractor,
statusBarService, notificationShadeWindowController, sysuiState, statusBarService, notificationShadeWindowController, sysuiState,
onRotateCallback, keyguardShowing, powerAdapter, uiEventLogger); onRotateCallback, keyguardShowing, powerAdapter, uiEventLogger, null);
mWalletFactory = walletFactory; mWalletFactory = walletFactory;
// Update window attributes // Update window attributes

View File

@@ -188,6 +188,7 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene
private final UiEventLogger mUiEventLogger; private final UiEventLogger mUiEventLogger;
private final NotificationShadeDepthController mDepthController; private final NotificationShadeDepthController mDepthController;
private final SysUiState mSysUiState; private final SysUiState mSysUiState;
private final GlobalActionsInfoProvider mInfoProvider;
// Used for RingerModeTracker // Used for RingerModeTracker
private final LifecycleRegistry mLifecycle = new LifecycleRegistry(this); private final LifecycleRegistry mLifecycle = new LifecycleRegistry(this);
@@ -320,6 +321,7 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene
IWindowManager iWindowManager, IWindowManager iWindowManager,
@Background Executor backgroundExecutor, @Background Executor backgroundExecutor,
UiEventLogger uiEventLogger, UiEventLogger uiEventLogger,
GlobalActionsInfoProvider infoProvider,
RingerModeTracker ringerModeTracker, SysUiState sysUiState, @Main Handler handler) { RingerModeTracker ringerModeTracker, SysUiState sysUiState, @Main Handler handler) {
mContext = context; mContext = context;
mWindowManagerFuncs = windowManagerFuncs; mWindowManagerFuncs = windowManagerFuncs;
@@ -339,6 +341,7 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene
mTelecomManager = telecomManager; mTelecomManager = telecomManager;
mMetricsLogger = metricsLogger; mMetricsLogger = metricsLogger;
mUiEventLogger = uiEventLogger; mUiEventLogger = uiEventLogger;
mInfoProvider = infoProvider;
mDepthController = depthController; mDepthController = depthController;
mSysuiColorExtractor = colorExtractor; mSysuiColorExtractor = colorExtractor;
mStatusBarService = statusBarService; mStatusBarService = statusBarService;
@@ -621,7 +624,8 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene
mAdapter, mOverflowAdapter, mAdapter, mOverflowAdapter,
mDepthController, mSysuiColorExtractor, mDepthController, mSysuiColorExtractor,
mStatusBarService, mNotificationShadeWindowController, mStatusBarService, mNotificationShadeWindowController,
mSysUiState, this::onRotate, mKeyguardShowing, mPowerAdapter, mUiEventLogger); mSysUiState, this::onRotate, mKeyguardShowing, mPowerAdapter, mUiEventLogger,
mInfoProvider);
dialog.setOnDismissListener(this); dialog.setOnDismissListener(this);
dialog.setOnShowListener(this); dialog.setOnShowListener(this);
@@ -2095,6 +2099,7 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene
private Dialog mPowerOptionsDialog; private Dialog mPowerOptionsDialog;
protected final Runnable mOnRotateCallback; protected final Runnable mOnRotateCallback;
private UiEventLogger mUiEventLogger; private UiEventLogger mUiEventLogger;
private GlobalActionsInfoProvider mInfoProvider;
protected ViewGroup mContainer; protected ViewGroup mContainer;
@@ -2104,7 +2109,8 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene
SysuiColorExtractor sysuiColorExtractor, IStatusBarService statusBarService, SysuiColorExtractor sysuiColorExtractor, IStatusBarService statusBarService,
NotificationShadeWindowController notificationShadeWindowController, NotificationShadeWindowController notificationShadeWindowController,
SysUiState sysuiState, Runnable onRotateCallback, boolean keyguardShowing, SysUiState sysuiState, Runnable onRotateCallback, boolean keyguardShowing,
MyPowerOptionsAdapter powerAdapter, UiEventLogger uiEventLogger) { MyPowerOptionsAdapter powerAdapter, UiEventLogger uiEventLogger,
@Nullable GlobalActionsInfoProvider infoProvider) {
super(context, themeRes); super(context, themeRes);
mContext = context; mContext = context;
mAdapter = adapter; mAdapter = adapter;
@@ -2118,6 +2124,7 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene
mOnRotateCallback = onRotateCallback; mOnRotateCallback = onRotateCallback;
mKeyguardShowing = keyguardShowing; mKeyguardShowing = keyguardShowing;
mUiEventLogger = uiEventLogger; mUiEventLogger = uiEventLogger;
mInfoProvider = infoProvider;
// Window initialization // Window initialization
Window window = getWindow(); Window window = getWindow();
@@ -2215,6 +2222,10 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene
mBackgroundDrawable = new ScrimDrawable(); mBackgroundDrawable = new ScrimDrawable();
mScrimAlpha = 1.0f; mScrimAlpha = 1.0f;
} }
if (mInfoProvider != null && mInfoProvider.shouldShowMessage()) {
mInfoProvider.addPanel(mContext, mContainer, mAdapter.getCount(), () -> dismiss());
}
} }
protected void fixNavBarClipping() { protected void fixNavBarClipping() {

View File

@@ -0,0 +1,38 @@
/*
* Copyright (C) 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.systemui.globalactions
import android.content.Context
import android.service.quickaccesswallet.QuickAccessWalletClient
import android.view.ViewGroup
import com.android.systemui.controls.controller.ControlsController
import com.android.systemui.plugins.ActivityStarter
import javax.inject.Inject
// Empty class, will be overridden for relevant devices
class GlobalActionsInfoProvider @Inject constructor(
private val context: Context,
private val walletClient: QuickAccessWalletClient,
private val controlsController: ControlsController,
private val activityStarter: ActivityStarter
) {
fun addPanel(context: Context, parent: ViewGroup, nActions: Int, dismissParent: Runnable) { }
fun shouldShowMessage(): Boolean {
return false
}
}

View File

@@ -103,6 +103,7 @@ public class GlobalActionsDialogLiteTest extends SysuiTestCase {
@Mock private IWindowManager mWindowManager; @Mock private IWindowManager mWindowManager;
@Mock private Executor mBackgroundExecutor; @Mock private Executor mBackgroundExecutor;
@Mock private UiEventLogger mUiEventLogger; @Mock private UiEventLogger mUiEventLogger;
@Mock private GlobalActionsInfoProvider mInfoProvider;
@Mock private RingerModeTracker mRingerModeTracker; @Mock private RingerModeTracker mRingerModeTracker;
@Mock private RingerModeLiveData mRingerModeLiveData; @Mock private RingerModeLiveData mRingerModeLiveData;
@Mock private SysUiState mSysUiState; @Mock private SysUiState mSysUiState;
@@ -146,6 +147,7 @@ public class GlobalActionsDialogLiteTest extends SysuiTestCase {
mWindowManager, mWindowManager,
mBackgroundExecutor, mBackgroundExecutor,
mUiEventLogger, mUiEventLogger,
mInfoProvider,
mRingerModeTracker, mRingerModeTracker,
mSysUiState, mSysUiState,
mHandler mHandler

View File

@@ -0,0 +1,73 @@
/*
* Copyright (C) 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.systemui.globalactions
import android.service.quickaccesswallet.QuickAccessWalletClient
import android.testing.AndroidTestingRunner
import android.view.ViewGroup
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.controls.controller.ControlsController
import com.android.systemui.plugins.ActivityStarter
import com.google.common.truth.Truth.assertThat
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.ArgumentMatchers.anyInt
import org.mockito.ArgumentMatchers.anyObject
import org.mockito.Mock
import org.mockito.Mockito.mock
import org.mockito.Mockito.verify
import org.mockito.Mockito.never
import org.mockito.MockitoAnnotations
@SmallTest
@RunWith(AndroidTestingRunner::class)
class GlobalActionsInfoProviderTest : SysuiTestCase() {
@Mock
private lateinit var walletClient: QuickAccessWalletClient
@Mock
private lateinit var controlsController: ControlsController
@Mock
private lateinit var activityStarter: ActivityStarter
private lateinit var infoProvider: GlobalActionsInfoProvider
@Before
fun setup() {
MockitoAnnotations.initMocks(this)
infoProvider = GlobalActionsInfoProvider(
context,
walletClient,
controlsController,
activityStarter
)
}
@Test
fun testAddPanel_doesNothing() {
val parent = mock(ViewGroup::class.java)
infoProvider.addPanel(context, parent, 1, { })
verify(parent, never()).addView(anyObject(), anyInt())
}
@Test
fun testShouldShowPanel() {
assertThat(infoProvider.shouldShowMessage()).isFalse()
}
}