diff options
| -rw-r--r-- | packages/SystemUI/res/values/dimens.xml | 5 | ||||
| -rw-r--r-- | packages/SystemUI/shared/src/com/android/systemui/shared/navigationbar/RegionSamplingHelper.java (renamed from packages/SystemUI/src/com/android/systemui/navigationbar/gestural/RegionSamplingHelper.java) | 26 | ||||
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarView.java | 2 | ||||
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/navigationbar/gestural/NavigationBarEdgePanel.java | 1 |
4 files changed, 16 insertions, 18 deletions
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml index b13b34c8fb31..e4125487b3fa 100644 --- a/packages/SystemUI/res/values/dimens.xml +++ b/packages/SystemUI/res/values/dimens.xml @@ -56,11 +56,6 @@ <!-- The amount by which the arrow is shifted to avoid the finger--> <dimen name="navigation_edge_finger_offset">48dp</dimen> - <!-- Luminance threshold to determine black/white contrast for the navigation affordances --> - <item name="navigation_luminance_threshold" type="dimen" format="float">0.5</item> - <!-- Luminance change threshold that allows applying new value if difference was exceeded --> - <item name="navigation_luminance_change_threshold" type="dimen" format="float">0.05</item> - <dimen name="floating_rotation_button_diameter">40dp</dimen> <dimen name="floating_rotation_button_min_margin">20dp</dimen> <dimen name="floating_rotation_button_taskbar_left_margin">20dp</dimen> diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/RegionSamplingHelper.java b/packages/SystemUI/shared/src/com/android/systemui/shared/navigationbar/RegionSamplingHelper.java index c9a939974cc9..bcfb77461307 100644 --- a/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/RegionSamplingHelper.java +++ b/packages/SystemUI/shared/src/com/android/systemui/shared/navigationbar/RegionSamplingHelper.java @@ -14,12 +14,13 @@ * limitations under the License. */ -package com.android.systemui.navigationbar.gestural; +package com.android.systemui.shared.navigationbar; import static android.view.Display.DEFAULT_DISPLAY; -import android.content.res.Resources; +import android.annotation.TargetApi; import android.graphics.Rect; +import android.os.Build; import android.os.Handler; import android.view.CompositionSamplingListener; import android.view.SurfaceControl; @@ -27,17 +28,22 @@ import android.view.View; import android.view.ViewRootImpl; import android.view.ViewTreeObserver; -import com.android.systemui.R; - import java.io.PrintWriter; import java.util.concurrent.Executor; /** * A helper class to sample regions on the screen and inspect its luminosity. */ +@TargetApi(Build.VERSION_CODES.Q) public class RegionSamplingHelper implements View.OnAttachStateChangeListener, View.OnLayoutChangeListener { + // Luminance threshold to determine black/white contrast for the navigation affordances. + // Passing the threshold of this luminance value will make the button black otherwise white + private static final float NAVIGATION_LUMINANCE_THRESHOLD = 0.5f; + // Luminance change threshold that allows applying new value if difference was exceeded + private static final float NAVIGATION_LUMINANCE_CHANGE_THRESHOLD = 0.05f; + private final Handler mHandler = new Handler(); private final View mSampledView; @@ -62,9 +68,6 @@ public class RegionSamplingHelper implements View.OnAttachStateChangeListener, private boolean mWaitingOnDraw; private boolean mIsDestroyed; - // Passing the threshold of this luminance value will make the button black otherwise white - private final float mLuminanceThreshold; - private final float mLuminanceChangeThreshold; private boolean mFirstSamplingAfterStart; private boolean mWindowVisible; private boolean mWindowHasBlurs; @@ -100,9 +103,6 @@ public class RegionSamplingHelper implements View.OnAttachStateChangeListener, mSampledView.addOnAttachStateChangeListener(this); mSampledView.addOnLayoutChangeListener(this); - final Resources res = sampledView.getResources(); - mLuminanceThreshold = res.getFloat(R.dimen.navigation_luminance_threshold); - mLuminanceChangeThreshold = res.getFloat(R.dimen.navigation_luminance_change_threshold); mCallback = samplingCallback; } @@ -217,8 +217,10 @@ public class RegionSamplingHelper implements View.OnAttachStateChangeListener, // If the difference between the new luma and the current luma is larger than threshold // then apply the current luma, this is to prevent small changes causing colors to flicker - if (Math.abs(mCurrentMedianLuma - mLastMedianLuma) > mLuminanceChangeThreshold) { - mCallback.onRegionDarknessChanged(medianLuma < mLuminanceThreshold /* isRegionDark */); + if (Math.abs(mCurrentMedianLuma - mLastMedianLuma) + > NAVIGATION_LUMINANCE_CHANGE_THRESHOLD) { + mCallback.onRegionDarknessChanged( + medianLuma < NAVIGATION_LUMINANCE_THRESHOLD /* isRegionDark */); mLastMedianLuma = medianLuma; } } diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarView.java index 2d36de34ad04..93388f93991f 100644 --- a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarView.java +++ b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarView.java @@ -79,7 +79,7 @@ import com.android.systemui.navigationbar.buttons.NearestTouchFrame; import com.android.systemui.navigationbar.buttons.RotationContextButton; import com.android.systemui.navigationbar.gestural.EdgeBackGestureHandler; import com.android.systemui.navigationbar.gestural.FloatingRotationButton; -import com.android.systemui.navigationbar.gestural.RegionSamplingHelper; +import com.android.systemui.shared.navigationbar.RegionSamplingHelper; import com.android.systemui.recents.OverviewProxyService; import com.android.systemui.recents.Recents; import com.android.systemui.shared.system.ActivityManagerWrapper; diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/NavigationBarEdgePanel.java b/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/NavigationBarEdgePanel.java index ea04cefb8f70..8d1dfc842fba 100644 --- a/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/NavigationBarEdgePanel.java +++ b/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/NavigationBarEdgePanel.java @@ -55,6 +55,7 @@ import com.android.systemui.Dependency; import com.android.systemui.R; import com.android.systemui.animation.Interpolators; import com.android.systemui.plugins.NavigationEdgeBackPlugin; +import com.android.systemui.shared.navigationbar.RegionSamplingHelper; import com.android.systemui.statusbar.VibratorHelper; import java.io.PrintWriter; |