Merge "Revive DeadZone" into oc-dev
am: b278424fa6
Change-Id: I5a06302eaad1e955aaea6ae8d2785c0b12e53cc4
This commit is contained in:
@@ -224,6 +224,14 @@ public final class MotionEvent extends InputEvent implements Parcelable {
|
|||||||
* Constant for {@link #getActionMasked}: A movement has happened outside of the
|
* Constant for {@link #getActionMasked}: A movement has happened outside of the
|
||||||
* normal bounds of the UI element. This does not provide a full gesture,
|
* normal bounds of the UI element. This does not provide a full gesture,
|
||||||
* but only the initial location of the movement/touch.
|
* 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;
|
public static final int ACTION_OUTSIDE = 4;
|
||||||
|
|
||||||
|
|||||||
@@ -16,11 +16,11 @@
|
|||||||
** limitations under the License.
|
** limitations under the License.
|
||||||
*/
|
*/
|
||||||
-->
|
-->
|
||||||
<FrameLayout
|
<com.android.systemui.statusbar.phone.NavigationBarFrame
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:systemui="http://schemas.android.com/apk/res-auto"
|
xmlns:systemui="http://schemas.android.com/apk/res-auto"
|
||||||
android:id="@+id/navigation_bar_frame"
|
android:id="@+id/navigation_bar_frame"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_width="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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -249,9 +249,6 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
|
|||||||
if (mGestureHelper.onTouchEvent(event)) {
|
if (mGestureHelper.onTouchEvent(event)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (mDeadZone != null && event.getAction() == MotionEvent.ACTION_OUTSIDE) {
|
|
||||||
mDeadZone.poke(event);
|
|
||||||
}
|
|
||||||
return super.onTouchEvent(event);
|
return super.onTouchEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -612,9 +609,8 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
|
|||||||
public void reorient() {
|
public void reorient() {
|
||||||
updateCurrentView();
|
updateCurrentView();
|
||||||
|
|
||||||
getImeSwitchButton().setOnClickListener(mImeSwitcherClickListener);
|
|
||||||
|
|
||||||
mDeadZone = (DeadZone) mCurrentView.findViewById(R.id.deadzone);
|
mDeadZone = (DeadZone) mCurrentView.findViewById(R.id.deadzone);
|
||||||
|
((NavigationBarFrame) getRootView()).setDeadZone(mDeadZone);
|
||||||
mDeadZone.setDisplayRotation(mCurrentRotation);
|
mDeadZone.setDisplayRotation(mCurrentRotation);
|
||||||
|
|
||||||
// force the low profile & disabled states into compliance
|
// force the low profile & disabled states into compliance
|
||||||
|
|||||||
@@ -127,6 +127,7 @@ public class DeadZone extends View {
|
|||||||
final int action = event.getAction();
|
final int action = event.getAction();
|
||||||
if (action == MotionEvent.ACTION_OUTSIDE) {
|
if (action == MotionEvent.ACTION_OUTSIDE) {
|
||||||
poke(event);
|
poke(event);
|
||||||
|
return true;
|
||||||
} else if (action == MotionEvent.ACTION_DOWN) {
|
} else if (action == MotionEvent.ACTION_DOWN) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Slog.v(TAG, this + " ACTION_DOWN: " + event.getX() + "," + event.getY());
|
Slog.v(TAG, this + " ACTION_DOWN: " + event.getX() + "," + event.getY());
|
||||||
@@ -158,7 +159,7 @@ public class DeadZone extends View {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void poke(MotionEvent event) {
|
private void poke(MotionEvent event) {
|
||||||
mLastPokeTime = event.getEventTime();
|
mLastPokeTime = event.getEventTime();
|
||||||
if (DEBUG)
|
if (DEBUG)
|
||||||
Slog.v(TAG, "poked! size=" + getSize(mLastPokeTime));
|
Slog.v(TAG, "poked! size=" + getSize(mLastPokeTime));
|
||||||
|
|||||||
@@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
package com.android.systemui.statusbar.phone;
|
package com.android.systemui.statusbar.phone;
|
||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
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.stackdivider.Divider;
|
||||||
import com.android.systemui.statusbar.CommandQueue;
|
import com.android.systemui.statusbar.CommandQueue;
|
||||||
import com.android.systemui.statusbar.policy.AccessibilityManagerWrapper;
|
import com.android.systemui.statusbar.policy.AccessibilityManagerWrapper;
|
||||||
import com.android.systemui.utils.leaks.BaseLeakChecker;
|
|
||||||
|
|
||||||
import android.testing.TestableLooper.RunWithLooper;
|
import android.testing.TestableLooper.RunWithLooper;
|
||||||
import android.view.accessibility.AccessibilityManager;
|
|
||||||
import android.view.accessibility.AccessibilityManager.AccessibilityServicesStateChangeListener;
|
import android.view.accessibility.AccessibilityManager.AccessibilityServicesStateChangeListener;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.invocation.InvocationOnMock;
|
|
||||||
import org.mockito.stubbing.Answer;
|
|
||||||
|
|
||||||
@RunWith(AndroidTestingRunner.class)
|
@RunWith(AndroidTestingRunner.class)
|
||||||
@RunWithLooper(setAsMainLooper = true)
|
@RunWithLooper(setAsMainLooper = true)
|
||||||
@@ -54,6 +49,10 @@ public class NavigationBarFragmentTest extends SysuiBaseFragmentTest {
|
|||||||
super(NavigationBarFragment.class);
|
super(NavigationBarFragment.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void createRootView() {
|
||||||
|
mView = new NavigationBarFrame(mContext);
|
||||||
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
mDependency.injectTestDependency(Dependency.BG_LOOPER, Looper.getMainLooper());
|
mDependency.injectTestDependency(Dependency.BG_LOOPER, Looper.getMainLooper());
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public abstract class BaseFragmentTest {
|
|||||||
private static final int VIEW_ID = 42;
|
private static final int VIEW_ID = 42;
|
||||||
private final Class<? extends Fragment> mCls;
|
private final Class<? extends Fragment> mCls;
|
||||||
private Handler mHandler;
|
private Handler mHandler;
|
||||||
private FrameLayout mView;
|
protected FrameLayout mView;
|
||||||
protected FragmentController mFragments;
|
protected FragmentController mFragments;
|
||||||
protected Fragment mFragment;
|
protected Fragment mFragment;
|
||||||
|
|
||||||
@@ -61,9 +61,13 @@ public abstract class BaseFragmentTest {
|
|||||||
mCls = cls;
|
mCls = cls;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void createRootView() {
|
||||||
|
mView = new FrameLayout(mContext);
|
||||||
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setupFragment() throws Exception {
|
public void setupFragment() throws Exception {
|
||||||
mView = new FrameLayout(mContext);
|
createRootView();
|
||||||
mView.setId(VIEW_ID);
|
mView.setId(VIEW_ID);
|
||||||
|
|
||||||
assertNotNull("BaseFragmentTest must be tagged with @RunWithLooper",
|
assertNotNull("BaseFragmentTest must be tagged with @RunWithLooper",
|
||||||
|
|||||||
Reference in New Issue
Block a user