Merge "Hide padlock when launching camera" into qt-dev

am: b82f6d6436

Change-Id: Icf7d6f9f4e425f93b76e69e3af85f7d02a53d0e1
This commit is contained in:
Lucas Dupin
2019-05-22 16:41:17 -07:00
committed by android-build-merger
5 changed files with 61 additions and 2 deletions

View File

@@ -95,6 +95,7 @@ public class LockIcon extends KeyguardAffordanceView implements OnUserInfoChange
private boolean mWasPulsingOnThisFrame;
private boolean mWakeAndUnlockRunning;
private boolean mKeyguardShowing;
private boolean mShowingLaunchAffordance;
private final KeyguardMonitor.Callback mKeyguardMonitorCallback =
new KeyguardMonitor.Callback() {
@@ -299,7 +300,8 @@ public class LockIcon extends KeyguardAffordanceView implements OnUserInfoChange
}
boolean onAodNotPulsingOrDocked = mDozing && (!mPulsing || mDocked);
boolean invisible = onAodNotPulsingOrDocked || mWakeAndUnlockRunning;
boolean invisible = onAodNotPulsingOrDocked || mWakeAndUnlockRunning
|| mShowingLaunchAffordance;
setVisibility(invisible ? INVISIBLE : VISIBLE);
updateClickability();
}
@@ -484,6 +486,14 @@ public class LockIcon extends KeyguardAffordanceView implements OnUserInfoChange
update();
}
/**
* When we're launching an affordance, like double pressing power to open camera.
*/
public void onShowingLaunchAffordanceChanged(boolean showing) {
mShowingLaunchAffordance = showing;
update();
}
/**
* Called whenever the scrims become opaque, transparent or semi-transparent.
*/

View File

@@ -151,7 +151,8 @@ public class NotificationPanelView extends PanelView implements
private final NotificationWakeUpCoordinator mWakeUpCoordinator;
private final PulseExpansionHandler mPulseExpansionHandler;
private KeyguardAffordanceHelper mAffordanceHelper;
@VisibleForTesting
protected KeyguardAffordanceHelper mAffordanceHelper;
private KeyguardUserSwitcher mKeyguardUserSwitcher;
@VisibleForTesting
protected KeyguardStatusBarView mKeyguardStatusBar;
@@ -340,6 +341,7 @@ public class NotificationPanelView extends PanelView implements
*/
private int mThemeResId;
private KeyguardIndicationController mKeyguardIndicationController;
private Consumer<Boolean> mAffordanceLaunchListener;
@Inject
public NotificationPanelView(@Named(VIEW_CONTEXT) Context context, AttributeSet attrs,
@@ -447,6 +449,14 @@ public class NotificationPanelView extends PanelView implements
R.dimen.qs_notification_padding);
}
/**
* @see #launchCamera(boolean, int)
* @see #setLaunchingAffordance(boolean)
*/
public void setLaunchAffordanceListener(Consumer<Boolean> listener) {
mAffordanceLaunchListener = listener;
}
public void updateResources() {
Resources res = getResources();
int qsWidth = res.getDimensionPixelSize(R.dimen.qs_panel_width);
@@ -2743,6 +2753,9 @@ public class NotificationPanelView extends PanelView implements
private void setLaunchingAffordance(boolean launchingAffordance) {
getLeftIcon().setLaunchingAffordance(launchingAffordance);
getRightIcon().setLaunchingAffordance(launchingAffordance);
if (mAffordanceLaunchListener != null) {
mAffordanceLaunchListener.accept(launchingAffordance);
}
}
/**

View File

@@ -951,6 +951,9 @@ public class StatusBar extends SystemUI implements DemoMode,
createUserSwitcher();
}
mNotificationPanel.setLaunchAffordanceListener(
mStatusBarWindow::onShowingLaunchAffordanceChanged);
// Set up the quick settings tile panel
View container = mStatusBarWindow.findViewById(R.id.qs_frame);
if (container != null) {

View File

@@ -510,6 +510,15 @@ public class StatusBarWindowView extends FrameLayout {
}
}
/**
* When we're launching an affordance, like double pressing power to open camera.
*/
public void onShowingLaunchAffordanceChanged(boolean showing) {
if (mLockIcon != null) {
mLockIcon.onShowingLaunchAffordanceChanged(showing);
}
}
public class LayoutParams extends FrameLayout.LayoutParams {
public boolean ignoreRightInset;

View File

@@ -21,9 +21,11 @@ import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.app.StatusBarManager;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import android.view.MotionEvent;
@@ -36,6 +38,7 @@ import com.android.systemui.SystemUIFactory;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.AmbientPulseManager;
import com.android.systemui.statusbar.KeyguardAffordanceView;
import com.android.systemui.statusbar.NotificationLockscreenUserManager;
import com.android.systemui.statusbar.NotificationShelf;
import com.android.systemui.statusbar.PulseExpansionHandler;
@@ -55,6 +58,8 @@ import org.mockito.InOrder;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import java.util.function.Consumer;
@SmallTest
@RunWith(AndroidTestingRunner.class)
@TestableLooper.RunWithLooper
@@ -90,6 +95,8 @@ public class NotificationPanelViewTest extends SysuiTestCase {
private HeadsUpTouchHelper.Callback mHeadsUpCallback;
@Mock
private PanelBar mPanelBar;
@Mock
private KeyguardAffordanceHelper mAffordanceHelper;
private NotificationPanelView mNotificationPanelView;
@Before
@@ -112,6 +119,9 @@ public class NotificationPanelViewTest extends SysuiTestCase {
mNotificationPanelView = new TestableNotificationPanelView(coordinator, expansionHandler);
mNotificationPanelView.setHeadsUpManager(mHeadsUpManager);
mNotificationPanelView.setBar(mPanelBar);
when(mKeyguardBottomArea.getLeftView()).thenReturn(mock(KeyguardAffordanceView.class));
when(mKeyguardBottomArea.getRightView()).thenReturn(mock(KeyguardAffordanceView.class));
}
@Test
@@ -128,6 +138,19 @@ public class NotificationPanelViewTest extends SysuiTestCase {
assertThat((int) mNotificationPanelView.getExpandedHeight()).isEqualTo(200);
}
@Test
public void testAffordanceLaunchingListener() {
Consumer<Boolean> listener = spy((showing) -> { });
mNotificationPanelView.setExpandedFraction(1f);
mNotificationPanelView.setLaunchAffordanceListener(listener);
mNotificationPanelView.launchCamera(false /* animate */,
StatusBarManager.CAMERA_LAUNCH_SOURCE_POWER_DOUBLE_TAP);
verify(listener).accept(eq(true));
mNotificationPanelView.onAffordanceLaunchEnded();
verify(listener).accept(eq(false));
}
@Test
public void testOnTouchEvent_expansionCanBeBlocked() {
mNotificationPanelView.onTouchEvent(MotionEvent.obtain(0L /* downTime */,
@@ -166,6 +189,7 @@ public class NotificationPanelViewTest extends SysuiTestCase {
mKeyguardBottomArea = NotificationPanelViewTest.this.mKeyguardBottomArea;
mBigClockContainer = NotificationPanelViewTest.this.mBigClockContainer;
mQsFrame = NotificationPanelViewTest.this.mQsFrame;
mAffordanceHelper = NotificationPanelViewTest.this.mAffordanceHelper;
initDependencies(NotificationPanelViewTest.this.mStatusBar,
NotificationPanelViewTest.this.mGroupManager,
NotificationPanelViewTest.this.mNotificationShelf,