Merge "Auto dim the nav bar to help prevent diff aging" into oc-mr1-dev
This commit is contained in:
@@ -75,6 +75,10 @@ public class BarTransitions {
|
|||||||
return mMode;
|
return mMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setAutoDim(boolean autoDim) {
|
||||||
|
// Default is don't care.
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param alwaysOpaque if {@code true}, the bar's background will always be opaque, regardless
|
* @param alwaysOpaque if {@code true}, the bar's background will always be opaque, regardless
|
||||||
* of what mode it is currently set to.
|
* of what mode it is currently set to.
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ public final class NavigationBarTransitions extends BarTransitions {
|
|||||||
private final LightBarTransitionsController mLightTransitionsController;
|
private final LightBarTransitionsController mLightTransitionsController;
|
||||||
|
|
||||||
private boolean mLightsOut;
|
private boolean mLightsOut;
|
||||||
|
private boolean mAutoDim;
|
||||||
|
|
||||||
public NavigationBarTransitions(NavigationBarView view) {
|
public NavigationBarTransitions(NavigationBarView view) {
|
||||||
super(view, R.drawable.nav_background);
|
super(view, R.drawable.nav_background);
|
||||||
@@ -44,7 +45,19 @@ public final class NavigationBarTransitions extends BarTransitions {
|
|||||||
|
|
||||||
public void init() {
|
public void init() {
|
||||||
applyModeBackground(-1, getMode(), false /*animate*/);
|
applyModeBackground(-1, getMode(), false /*animate*/);
|
||||||
applyMode(getMode(), false /*animate*/, true /*force*/);
|
applyLightsOut(false /*animate*/, true /*force*/);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setAutoDim(boolean autoDim) {
|
||||||
|
if (mAutoDim == autoDim) return;
|
||||||
|
mAutoDim = autoDim;
|
||||||
|
applyLightsOut(true, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isLightsOut(int mode) {
|
||||||
|
return super.isLightsOut(mode) || mAutoDim;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LightBarTransitionsController getLightTransitionsController() {
|
public LightBarTransitionsController getLightTransitionsController() {
|
||||||
@@ -54,13 +67,12 @@ public final class NavigationBarTransitions extends BarTransitions {
|
|||||||
@Override
|
@Override
|
||||||
protected void onTransition(int oldMode, int newMode, boolean animate) {
|
protected void onTransition(int oldMode, int newMode, boolean animate) {
|
||||||
super.onTransition(oldMode, newMode, animate);
|
super.onTransition(oldMode, newMode, animate);
|
||||||
applyMode(newMode, animate, false /*force*/);
|
applyLightsOut(animate, false /*force*/);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applyMode(int mode, boolean animate, boolean force) {
|
private void applyLightsOut(boolean animate, boolean force) {
|
||||||
|
|
||||||
// apply to lights out
|
// apply to lights out
|
||||||
applyLightsOut(isLightsOut(mode), animate, force);
|
applyLightsOut(isLightsOut(getMode()), animate, force);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applyLightsOut(boolean lightsOut, boolean animate, boolean force) {
|
private void applyLightsOut(boolean lightsOut, boolean animate, boolean force) {
|
||||||
@@ -86,7 +98,6 @@ public final class NavigationBarTransitions extends BarTransitions {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void reapplyDarkIntensity() {
|
public void reapplyDarkIntensity() {
|
||||||
applyDarkIntensity(mLightTransitionsController.getCurrentDarkIntensity());
|
applyDarkIntensity(mLightTransitionsController.getCurrentDarkIntensity());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -558,14 +558,12 @@ public class StatusBar extends SystemUI implements DemoMode,
|
|||||||
protected DozeScrimController mDozeScrimController;
|
protected DozeScrimController mDozeScrimController;
|
||||||
private final UiOffloadThread mUiOffloadThread = Dependency.get(UiOffloadThread.class);
|
private final UiOffloadThread mUiOffloadThread = Dependency.get(UiOffloadThread.class);
|
||||||
|
|
||||||
private final Runnable mAutohide = new Runnable() {
|
private final Runnable mAutohide = () -> {
|
||||||
@Override
|
int requested = mSystemUiVisibility & ~STATUS_OR_NAV_TRANSIENT;
|
||||||
public void run() {
|
if (mSystemUiVisibility != requested) {
|
||||||
int requested = mSystemUiVisibility & ~STATUS_OR_NAV_TRANSIENT;
|
notifyUiVisibilityChanged(requested);
|
||||||
if (mSystemUiVisibility != requested) {
|
}
|
||||||
notifyUiVisibilityChanged(requested);
|
};
|
||||||
}
|
|
||||||
}};
|
|
||||||
|
|
||||||
private boolean mWaitingForKeyguardExit;
|
private boolean mWaitingForKeyguardExit;
|
||||||
protected boolean mDozing;
|
protected boolean mDozing;
|
||||||
@@ -3322,6 +3320,7 @@ public class StatusBar extends SystemUI implements DemoMode,
|
|||||||
} else {
|
} else {
|
||||||
cancelAutohide();
|
cancelAutohide();
|
||||||
}
|
}
|
||||||
|
touchAutoDim();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int computeStatusBarMode(int oldVal, int newVal) {
|
protected int computeStatusBarMode(int oldVal, int newVal) {
|
||||||
@@ -3407,6 +3406,7 @@ public class StatusBar extends SystemUI implements DemoMode,
|
|||||||
dismissVolumeDialog();
|
dismissVolumeDialog();
|
||||||
}
|
}
|
||||||
checkBarModes();
|
checkBarModes();
|
||||||
|
touchAutoDim();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void dismissVolumeDialog() {
|
private void dismissVolumeDialog() {
|
||||||
@@ -3438,6 +3438,16 @@ public class StatusBar extends SystemUI implements DemoMode,
|
|||||||
mHandler.postDelayed(mAutohide, AUTOHIDE_TIMEOUT_MS);
|
mHandler.postDelayed(mAutohide, AUTOHIDE_TIMEOUT_MS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void touchAutoDim() {
|
||||||
|
if (mNavigationBar != null) {
|
||||||
|
mNavigationBar.getBarTransitions().setAutoDim(false);
|
||||||
|
}
|
||||||
|
mHandler.removeCallbacks(mAutoDim);
|
||||||
|
if (mState != StatusBarState.KEYGUARD && mState != StatusBarState.SHADE_LOCKED) {
|
||||||
|
mHandler.postDelayed(mAutoDim, AUTOHIDE_TIMEOUT_MS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void checkUserAutohide(View v, MotionEvent event) {
|
void checkUserAutohide(View v, MotionEvent event) {
|
||||||
if ((mSystemUiVisibility & STATUS_OR_NAV_TRANSIENT) != 0 // a transient bar is revealed
|
if ((mSystemUiVisibility & STATUS_OR_NAV_TRANSIENT) != 0 // a transient bar is revealed
|
||||||
&& event.getAction() == MotionEvent.ACTION_OUTSIDE // touch outside the source bar
|
&& event.getAction() == MotionEvent.ACTION_OUTSIDE // touch outside the source bar
|
||||||
@@ -4856,6 +4866,7 @@ public class StatusBar extends SystemUI implements DemoMode,
|
|||||||
updateReportRejectedTouchVisibility();
|
updateReportRejectedTouchVisibility();
|
||||||
updateDozing();
|
updateDozing();
|
||||||
updateTheme();
|
updateTheme();
|
||||||
|
touchAutoDim();
|
||||||
mNotificationShelf.setStatusBarState(state);
|
mNotificationShelf.setStatusBarState(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5371,6 +5382,7 @@ public class StatusBar extends SystemUI implements DemoMode,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void appTransitionFinished() {
|
public void appTransitionFinished() {
|
||||||
|
touchAutoDim();
|
||||||
EventBus.getDefault().send(new AppTransitionFinishedEvent());
|
EventBus.getDefault().send(new AppTransitionFinishedEvent());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -7560,4 +7572,10 @@ public class StatusBar extends SystemUI implements DemoMode,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// End Extra BaseStatusBarMethods.
|
// End Extra BaseStatusBarMethods.
|
||||||
|
|
||||||
|
private final Runnable mAutoDim = () -> {
|
||||||
|
if (mNavigationBar != null) {
|
||||||
|
mNavigationBar.getBarTransitions().setAutoDim(true);
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ import android.view.Surface;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
|
import com.android.systemui.SysUiServiceProvider;
|
||||||
|
import com.android.systemui.statusbar.phone.StatusBar;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The "dead zone" consumes unintentional taps along the top edge of the navigation bar.
|
* The "dead zone" consumes unintentional taps along the top edge of the navigation bar.
|
||||||
@@ -44,6 +46,7 @@ public class DeadZone extends View {
|
|||||||
public static final int VERTICAL = 1; // Consume taps along the left edge.
|
public static final int VERTICAL = 1; // Consume taps along the left edge.
|
||||||
|
|
||||||
private static final boolean CHATTY = true; // print to logcat when we eat a click
|
private static final boolean CHATTY = true; // print to logcat when we eat a click
|
||||||
|
private final StatusBar mStatusBar;
|
||||||
|
|
||||||
private boolean mShouldFlash;
|
private boolean mShouldFlash;
|
||||||
private float mFlashFrac = 0f;
|
private float mFlashFrac = 0f;
|
||||||
@@ -88,6 +91,7 @@ public class DeadZone extends View {
|
|||||||
+ (mVertical ? " vertical" : " horizontal"));
|
+ (mVertical ? " vertical" : " horizontal"));
|
||||||
|
|
||||||
setFlashOnTouchCapture(context.getResources().getBoolean(R.bool.config_dead_zone_flash));
|
setFlashOnTouchCapture(context.getResources().getBoolean(R.bool.config_dead_zone_flash));
|
||||||
|
mStatusBar = SysUiServiceProvider.getComponent(context, StatusBar.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
static float lerp(float a, float b, float f) {
|
static float lerp(float a, float b, float f) {
|
||||||
@@ -132,6 +136,7 @@ public class DeadZone extends View {
|
|||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Slog.v(TAG, this + " ACTION_DOWN: " + event.getX() + "," + event.getY());
|
Slog.v(TAG, this + " ACTION_DOWN: " + event.getX() + "," + event.getY());
|
||||||
}
|
}
|
||||||
|
if (mStatusBar != null) mStatusBar.touchAutoDim();
|
||||||
int size = (int) getSize(event.getEventTime());
|
int size = (int) getSize(event.getEventTime());
|
||||||
// In the vertical orientation consume taps along the left edge.
|
// In the vertical orientation consume taps along the left edge.
|
||||||
// In horizontal orientation consume taps along the top edge.
|
// In horizontal orientation consume taps along the top edge.
|
||||||
|
|||||||
@@ -0,0 +1,69 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2017 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.statusbar.phone;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.spy;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import android.support.test.filters.SmallTest;
|
||||||
|
import android.testing.AndroidTestingRunner;
|
||||||
|
import android.testing.TestableLooper.RunWithLooper;
|
||||||
|
|
||||||
|
import com.android.systemui.SysuiTestCase;
|
||||||
|
import com.android.systemui.statusbar.CommandQueue;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
@RunWith(AndroidTestingRunner.class)
|
||||||
|
@RunWithLooper
|
||||||
|
@SmallTest
|
||||||
|
public class NavigationBarTransitionsTest extends SysuiTestCase {
|
||||||
|
|
||||||
|
private NavigationBarTransitions mTransitions;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setup() {
|
||||||
|
mContext.putComponent(CommandQueue.class, mock(CommandQueue.class));
|
||||||
|
NavigationBarView navBar = spy(new NavigationBarView(mContext, null));
|
||||||
|
when(navBar.getCurrentView()).thenReturn(navBar);
|
||||||
|
when(navBar.findViewById(anyInt())).thenReturn(navBar);
|
||||||
|
mTransitions = new NavigationBarTransitions(navBar);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void setIsLightsOut_NoAutoDim() {
|
||||||
|
mTransitions.setAutoDim(false);
|
||||||
|
|
||||||
|
assertFalse(mTransitions.isLightsOut(BarTransitions.MODE_OPAQUE));
|
||||||
|
|
||||||
|
assertTrue(mTransitions.isLightsOut(BarTransitions.MODE_LIGHTS_OUT));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void setIsLightsOut_AutoDim() {
|
||||||
|
mTransitions.setAutoDim(true);
|
||||||
|
|
||||||
|
assertTrue(mTransitions.isLightsOut(BarTransitions.MODE_OPAQUE));
|
||||||
|
|
||||||
|
assertTrue(mTransitions.isLightsOut(BarTransitions.MODE_LIGHTS_OUT));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user