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

Commit c8422db0 authored by Winson Chung's avatar Winson Chung Committed by Android (Google) Code Review
Browse files

Merge "Remove empty NavBarGestureHelper class"

parents 39ff4f89 0d3815d9
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.view.View;

import com.android.systemui.plugins.Plugin;
import com.android.systemui.plugins.annotations.ProvidesInterface;
import java.io.PrintWriter;

@ProvidesInterface(action = NavGesture.ACTION, version = NavGesture.VERSION)
public interface NavGesture extends Plugin {
@@ -46,6 +47,8 @@ public interface NavGesture extends Plugin {
        public void onNavigationButtonLongPress(View v);

        public default void destroy() { }

        public default void dump(PrintWriter pw) { }
    }

}
+0 −85
Original line number Diff line number Diff line
/*
 * Copyright (C) 2014 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 android.content.Context;
import android.graphics.Canvas;
import android.view.MotionEvent;
import android.view.View;
import com.android.systemui.SysUiServiceProvider;
import com.android.systemui.plugins.statusbar.phone.NavGesture.GestureHelper;

/**
 * TODO: Remove and replace with QuickStepController
 */
public class NavigationBarGestureHelper implements GestureHelper {

    private static final String TAG = "NavigationBarGestureHelper";

    private NavigationBarView mNavigationBarView;

    private final QuickStepController mQuickStepController;
    private final StatusBar mStatusBar;

    public NavigationBarGestureHelper(Context context) {
        mStatusBar = SysUiServiceProvider.getComponent(context, StatusBar.class);
        mQuickStepController = new QuickStepController(context);
    }

    public void setComponents(NavigationBarView navigationBarView) {
        mNavigationBarView = navigationBarView;
        mQuickStepController.setComponents(mNavigationBarView);
    }

    public void setBarState(boolean isVertical, boolean isRTL) {
        mQuickStepController.setBarState(isVertical, isRTL);
    }

    public boolean onInterceptTouchEvent(MotionEvent event) {
        if (!canHandleGestures()) {
            return false;
        }
        return mQuickStepController.onInterceptTouchEvent(event);
    }

    public boolean onTouchEvent(MotionEvent event) {
        if (!canHandleGestures()) {
            return false;
        }
        return mQuickStepController.onTouchEvent(event);
    }

    public void onDraw(Canvas canvas) {
        mQuickStepController.onDraw(canvas);
    }

    public void onLayout(boolean changed, int left, int top, int right, int bottom) {
        mQuickStepController.onLayout(changed, left, top, right, bottom);
    }

    public void onDarkIntensityChange(float intensity) {
        mQuickStepController.onDarkIntensityChange(intensity);
    }

    public void onNavigationButtonLongPress(View v) {
        mQuickStepController.onNavigationButtonLongPress(v);
    }

    private boolean canHandleGestures() {
        return !mStatusBar.isKeyguardShowing();
    }
}
+4 −3
Original line number Diff line number Diff line
@@ -314,8 +314,8 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav

    public void setComponents(NotificationPanelView panel) {
        mPanelView = panel;
        if (mGestureHelper instanceof NavigationBarGestureHelper) {
            ((NavigationBarGestureHelper) mGestureHelper).setComponents(this);
        if (mGestureHelper instanceof QuickStepController) {
            ((QuickStepController) mGestureHelper).setComponents(this);
        }
    }

@@ -1071,7 +1071,7 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav

    @Override
    public void onPluginDisconnected(NavGesture plugin) {
        NavigationBarGestureHelper defaultHelper = new NavigationBarGestureHelper(getContext());
        QuickStepController defaultHelper = new QuickStepController(getContext());
        defaultHelper.setComponents(this);
        if (mGestureHelper != null) {
            mGestureHelper.destroy();
@@ -1117,6 +1117,7 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
        pw.println("    }");

        mContextualButtonGroup.dump(pw);
        mGestureHelper.dump(pw);
        mRecentsOnboarding.dump(pw);
    }

+28 −0
Original line number Diff line number Diff line
@@ -58,10 +58,12 @@ import com.android.systemui.Dependency;
import com.android.systemui.Interpolators;
import com.android.systemui.OverviewProxyService;
import com.android.systemui.R;
import com.android.systemui.SysUiServiceProvider;
import com.android.systemui.plugins.statusbar.phone.NavGesture.GestureHelper;
import com.android.systemui.shared.recents.IOverviewProxy;
import com.android.systemui.shared.recents.utilities.Utilities;
import com.android.systemui.shared.system.NavigationBarCompat;
import java.io.PrintWriter;

/**
 * Class to detect gestures on the navigation bar and implement quick scrub.
@@ -117,6 +119,7 @@ public class QuickStepController implements GestureHelper {
    private final int mTrackEndPadding;
    private final int mHomeBackGestureDragLimit;
    private final Context mContext;
    private final StatusBar mStatusBar;
    private final Matrix mTransformGlobalMatrix = new Matrix();
    private final Matrix mTransformLocalMatrix = new Matrix();
    private final Paint mTrackPaint = new Paint();
@@ -195,6 +198,7 @@ public class QuickStepController implements GestureHelper {
    public QuickStepController(Context context) {
        final Resources res = context.getResources();
        mContext = context;
        mStatusBar = SysUiServiceProvider.getComponent(context, StatusBar.class);
        mOverviewEventSender = Dependency.get(OverviewProxyService.class);
        mTrackThickness = res.getDimensionPixelSize(R.dimen.nav_quick_scrub_track_thickness);
        mTrackEndPadding = res.getDimensionPixelSize(R.dimen.nav_quick_scrub_track_edge_padding);
@@ -218,6 +222,10 @@ public class QuickStepController implements GestureHelper {
     */
    @Override
    public boolean onInterceptTouchEvent(MotionEvent event) {
        if (mStatusBar.isKeyguardShowing()) {
            // Disallow any handling when the keyguard is showing
            return false;
        }
        return handleTouchEvent(event);
    }

@@ -227,6 +235,11 @@ public class QuickStepController implements GestureHelper {
     */
    @Override
    public boolean onTouchEvent(MotionEvent event) {
        if (mStatusBar.isKeyguardShowing()) {
            // Disallow any handling when the keyguard is showing
            return false;
        }

        // The same down event was just sent on intercept and therefore can be ignored here
        final boolean ignoreProxyDownEvent = event.getAction() == MotionEvent.ACTION_DOWN
                && mOverviewEventSender.getProxy() != null;
@@ -483,6 +496,21 @@ public class QuickStepController implements GestureHelper {
        mHandler.removeCallbacksAndMessages(null);
    }

    @Override
    public void dump(PrintWriter pw) {
        pw.println("QuickStepController {");
        pw.print("    "); pw.println("mQuickScrubActive=" + mQuickScrubActive);
        pw.print("    "); pw.println("mQuickStepStarted=" + mQuickStepStarted);
        pw.print("    "); pw.println("mAllowGestureDetection=" + mAllowGestureDetection);
        pw.print("    "); pw.println("mBackGestureActive=" + mBackGestureActive);
        pw.print("    "); pw.println("mCanPerformBack=" + mCanPerformBack);
        pw.print("    "); pw.println("mNotificationsVisibleOnDown=" + mNotificationsVisibleOnDown);
        pw.print("    "); pw.println("mIsVertical=" + mIsVertical);
        pw.print("    "); pw.println("mIsRTL=" + mIsRTL);
        pw.print("    "); pw.println("mIsInScreenPinning=" + mIsInScreenPinning);
        pw.println("}");
    }

    private void startQuickStep(MotionEvent event) {
        if (mIsInScreenPinning) {
            mNavigationBarView.showPinningEscapeToast();