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

Commit 3b75827c authored by Jason Monk's avatar Jason Monk Committed by Android (Google) Code Review
Browse files

Merge "Add nav gesture plugin interface"

parents 0b277279 67e6c804
Loading
Loading
Loading
Loading
+37 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 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.plugins.statusbar.phone;

import android.view.MotionEvent;

import com.android.systemui.plugins.Plugin;

public interface NavGesture extends Plugin {

    public static final String ACTION = "com.android.systemui.action.PLUGIN_NAV_GESTURE";

    public static final int VERSION = 1;

    public GestureHelper getGestureHelper();

    public interface GestureHelper {
        public boolean onTouchEvent(MotionEvent event);

        public boolean onInterceptTouchEvent(MotionEvent event);

        public void setBarState(boolean vertical, boolean isRtl);
    }

}
+2 −1
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import com.android.internal.logging.MetricsProto.MetricsEvent;
import com.android.internal.policy.DividerSnapAlgorithm.SnapTarget;
import com.android.systemui.R;
import com.android.systemui.RecentsComponent;
import com.android.systemui.plugins.statusbar.phone.NavGesture.GestureHelper;
import com.android.systemui.stackdivider.Divider;
import com.android.systemui.tuner.TunerService;

@@ -42,7 +43,7 @@ import static android.view.WindowManager.DOCKED_TOP;
 * Class to detect gestures on the navigation bar.
 */
public class NavigationBarGestureHelper extends GestureDetector.SimpleOnGestureListener
        implements TunerService.Tunable {
        implements TunerService.Tunable, GestureHelper {

    private static final String KEY_DOCK_WINDOW_GESTURE = "overview_nav_bar_gesture";
    /**
+42 −4
Original line number Diff line number Diff line
@@ -44,16 +44,20 @@ import android.view.WindowManager;
import android.view.WindowManagerGlobal;
import android.view.inputmethod.InputMethodManager;
import android.widget.FrameLayout;
import android.widget.LinearLayout;

import com.android.systemui.R;
import com.android.systemui.RecentsComponent;
import com.android.systemui.plugins.PluginListener;
import com.android.systemui.plugins.PluginManager;
import com.android.systemui.plugins.statusbar.phone.NavGesture;
import com.android.systemui.plugins.statusbar.phone.NavGesture.GestureHelper;
import com.android.systemui.stackdivider.Divider;
import com.android.systemui.statusbar.policy.DeadZone;

import java.io.FileDescriptor;
import java.io.PrintWriter;

public class NavigationBarView extends FrameLayout {
public class NavigationBarView extends FrameLayout implements PluginListener<NavGesture> {
    final static boolean DEBUG = false;
    final static String TAG = "StatusBar/NavBarView";

@@ -83,7 +87,7 @@ public class NavigationBarView extends FrameLayout {
    private Drawable mImeIcon;
    private Drawable mMenuIcon;

    private NavigationBarGestureHelper mGestureHelper;
    private GestureHelper mGestureHelper;
    private DeadZone mDeadZone;
    private final NavigationBarTransitions mBarTransitions;

@@ -105,6 +109,8 @@ public class NavigationBarView extends FrameLayout {
    private Configuration mConfiguration;

    private NavigationBarInflaterView mNavigationInflaterView;
    private RecentsComponent mRecentsComponent;
    private Divider mDivider;

    private class NavTransitionListener implements TransitionListener {
        private boolean mBackTransitioning;
@@ -212,7 +218,12 @@ public class NavigationBarView extends FrameLayout {
    }

    public void setComponents(RecentsComponent recentsComponent, Divider divider) {
        mGestureHelper.setComponents(recentsComponent, divider, this);
        mRecentsComponent = recentsComponent;
        mDivider = divider;
        if (mGestureHelper instanceof NavigationBarGestureHelper) {
            ((NavigationBarGestureHelper) mGestureHelper).setComponents(
                    recentsComponent, divider, this);
        }
    }

    public void setOnVerticalChangedListener(OnVerticalChangedListener onVerticalChangedListener) {
@@ -700,6 +711,33 @@ public class NavigationBarView extends FrameLayout {
        }
    }

    @Override
    protected void onAttachedToWindow() {
        super.onAttachedToWindow();
        PluginManager.getInstance(getContext()).addPluginListener(NavGesture.ACTION, this,
                NavGesture.VERSION, false /* Only one */);
    }

    @Override
    protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        PluginManager.getInstance(getContext()).removePluginListener(this);
    }

    @Override
    public void onPluginConnected(NavGesture plugin) {
        mGestureHelper = plugin.getGestureHelper();
        updateTaskSwitchHelper();
    }

    @Override
    public void onPluginDisconnected(NavGesture plugin) {
        NavigationBarGestureHelper defaultHelper = new NavigationBarGestureHelper(getContext());
        defaultHelper.setComponents(mRecentsComponent, mDivider, this);
        mGestureHelper = defaultHelper;
        updateTaskSwitchHelper();
    }

    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
        pw.println("NavigationBarView {");
        final Rect r = new Rect();