Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ca7eb3f9 authored by Tracy Zhou's avatar Tracy Zhou Committed by Android (Google) Code Review
Browse files

Merge "Move RegionSamplingHelper to SysUI shared" into sc-v2-dev

parents 010be843 2e7147fc
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -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>
+14 −12
Original line number Diff line number Diff line
@@ -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;
        }
    }
+1 −1
Original line number Diff line number Diff line
@@ -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;
+1 −0
Original line number Diff line number Diff line
@@ -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;