1 /* 2 * Copyright (C) 2022 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.inputmethodservice.navigationbar; 18 19 import static android.view.MotionEvent.ACTION_OUTSIDE; 20 21 import android.annotation.AttrRes; 22 import android.annotation.NonNull; 23 import android.annotation.Nullable; 24 import android.content.Context; 25 import android.util.AttributeSet; 26 import android.view.MotionEvent; 27 import android.widget.FrameLayout; 28 29 /** 30 * @hide 31 */ 32 public final class NavigationBarFrame extends FrameLayout { 33 34 private DeadZone mDeadZone = null; 35 NavigationBarFrame(@onNull Context context)36 public NavigationBarFrame(@NonNull Context context) { 37 super(context); 38 } 39 NavigationBarFrame(Context context, AttributeSet attrs)40 public NavigationBarFrame(Context context, AttributeSet attrs) { 41 super(context, attrs); 42 } 43 NavigationBarFrame(@onNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr)44 public NavigationBarFrame(@NonNull Context context, @Nullable AttributeSet attrs, 45 @AttrRes int defStyleAttr) { 46 super(context, attrs, defStyleAttr); 47 } 48 setDeadZone(@onNull DeadZone deadZone)49 public void setDeadZone(@NonNull DeadZone deadZone) { 50 mDeadZone = deadZone; 51 } 52 53 @Override dispatchTouchEvent(MotionEvent event)54 public boolean dispatchTouchEvent(MotionEvent event) { 55 if (event.getAction() == ACTION_OUTSIDE) { 56 if (mDeadZone != null) { 57 return mDeadZone.onTouchEvent(event); 58 } 59 } 60 return super.dispatchTouchEvent(event); 61 } 62 } 63