Merge "Revive DeadZone" into oc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
b278424fa6
@@ -224,6 +224,14 @@ public final class MotionEvent extends InputEvent implements Parcelable {
|
||||
* Constant for {@link #getActionMasked}: A movement has happened outside of the
|
||||
* normal bounds of the UI element. This does not provide a full gesture,
|
||||
* but only the initial location of the movement/touch.
|
||||
* <p>
|
||||
* Note: Because the location of any event will be outside the
|
||||
* bounds of the view hierarchy, it will not get dispatched to
|
||||
* any children of a ViewGroup by default. Therefore,
|
||||
* movements with ACTION_OUTSIDE should be handled in either the
|
||||
* root {@link View} or in the appropriate {@link Window.Callback}
|
||||
* (e.g. {@link android.app.Activity} or {@link android.app.Dialog}).
|
||||
* </p>
|
||||
*/
|
||||
public static final int ACTION_OUTSIDE = 4;
|
||||
|
||||
|
||||
@@ -16,11 +16,11 @@
|
||||
** limitations under the License.
|
||||
*/
|
||||
-->
|
||||
<FrameLayout
|
||||
<com.android.systemui.statusbar.phone.NavigationBarFrame
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:systemui="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/navigation_bar_frame"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="match_parent">
|
||||
|
||||
</FrameLayout>
|
||||
</com.android.systemui.statusbar.phone.NavigationBarFrame>
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* 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 android.view.MotionEvent.ACTION_OUTSIDE;
|
||||
|
||||
import android.annotation.AttrRes;
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import com.android.systemui.statusbar.policy.DeadZone;
|
||||
|
||||
public class NavigationBarFrame extends FrameLayout {
|
||||
|
||||
private DeadZone mDeadZone = null;
|
||||
|
||||
public NavigationBarFrame(@NonNull Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public NavigationBarFrame(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public NavigationBarFrame(@NonNull Context context, @Nullable AttributeSet attrs,
|
||||
@AttrRes int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
public void setDeadZone(@NonNull DeadZone deadZone) {
|
||||
mDeadZone = deadZone;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dispatchTouchEvent(MotionEvent event) {
|
||||
if (event.getAction() == ACTION_OUTSIDE) {
|
||||
if (mDeadZone != null) {
|
||||
return mDeadZone.onTouchEvent(event);
|
||||
}
|
||||
}
|
||||
return super.dispatchTouchEvent(event);
|
||||
}
|
||||
}
|
||||
@@ -250,9 +250,6 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
|
||||
if (mGestureHelper.onTouchEvent(event)) {
|
||||
return true;
|
||||
}
|
||||
if (mDeadZone != null && event.getAction() == MotionEvent.ACTION_OUTSIDE) {
|
||||
mDeadZone.poke(event);
|
||||
}
|
||||
return super.onTouchEvent(event);
|
||||
}
|
||||
|
||||
@@ -614,9 +611,8 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
|
||||
public void reorient() {
|
||||
updateCurrentView();
|
||||
|
||||
getImeSwitchButton().setOnClickListener(mImeSwitcherClickListener);
|
||||
|
||||
mDeadZone = (DeadZone) mCurrentView.findViewById(R.id.deadzone);
|
||||
((NavigationBarFrame) getRootView()).setDeadZone(mDeadZone);
|
||||
mDeadZone.setDisplayRotation(mCurrentRotation);
|
||||
|
||||
// force the low profile & disabled states into compliance
|
||||
|
||||
@@ -127,6 +127,7 @@ public class DeadZone extends View {
|
||||
final int action = event.getAction();
|
||||
if (action == MotionEvent.ACTION_OUTSIDE) {
|
||||
poke(event);
|
||||
return true;
|
||||
} else if (action == MotionEvent.ACTION_DOWN) {
|
||||
if (DEBUG) {
|
||||
Slog.v(TAG, this + " ACTION_DOWN: " + event.getX() + "," + event.getY());
|
||||
@@ -158,7 +159,7 @@ public class DeadZone extends View {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void poke(MotionEvent event) {
|
||||
private void poke(MotionEvent event) {
|
||||
mLastPokeTime = event.getEventTime();
|
||||
if (DEBUG)
|
||||
Slog.v(TAG, "poked! size=" + getSize(mLastPokeTime));
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
package com.android.systemui.statusbar.phone;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@@ -33,17 +32,13 @@ import com.android.systemui.recents.Recents;
|
||||
import com.android.systemui.stackdivider.Divider;
|
||||
import com.android.systemui.statusbar.CommandQueue;
|
||||
import com.android.systemui.statusbar.policy.AccessibilityManagerWrapper;
|
||||
import com.android.systemui.utils.leaks.BaseLeakChecker;
|
||||
|
||||
import android.testing.TestableLooper.RunWithLooper;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
import android.view.accessibility.AccessibilityManager.AccessibilityServicesStateChangeListener;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
||||
@RunWith(AndroidTestingRunner.class)
|
||||
@RunWithLooper(setAsMainLooper = true)
|
||||
@@ -54,6 +49,10 @@ public class NavigationBarFragmentTest extends SysuiBaseFragmentTest {
|
||||
super(NavigationBarFragment.class);
|
||||
}
|
||||
|
||||
protected void createRootView() {
|
||||
mView = new NavigationBarFrame(mContext);
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
mDependency.injectTestDependency(Dependency.BG_LOOPER, Looper.getMainLooper());
|
||||
|
||||
@@ -50,7 +50,7 @@ public abstract class BaseFragmentTest {
|
||||
private static final int VIEW_ID = 42;
|
||||
private final Class<? extends Fragment> mCls;
|
||||
private Handler mHandler;
|
||||
private FrameLayout mView;
|
||||
protected FrameLayout mView;
|
||||
protected FragmentController mFragments;
|
||||
protected Fragment mFragment;
|
||||
|
||||
@@ -61,9 +61,13 @@ public abstract class BaseFragmentTest {
|
||||
mCls = cls;
|
||||
}
|
||||
|
||||
protected void createRootView() {
|
||||
mView = new FrameLayout(mContext);
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setupFragment() throws Exception {
|
||||
mView = new FrameLayout(mContext);
|
||||
createRootView();
|
||||
mView.setId(VIEW_ID);
|
||||
|
||||
assertNotNull("BaseFragmentTest must be tagged with @RunWithLooper",
|
||||
|
||||
Reference in New Issue
Block a user