Home | History | Annotate | Download | only in cts
      1 /*
      2  * Copyright (C) 2017 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.view.cts;
     18 
     19 import android.content.Context;
     20 import androidx.annotation.Nullable;
     21 import android.util.AttributeSet;
     22 import android.view.MotionEvent;
     23 import android.widget.LinearLayout;
     24 
     25 public class PointerCaptureGroup extends LinearLayout {
     26     private boolean mCalledDispatchPointerCaptureChanged;
     27     private boolean mCalledOnCapturedPointerEvent;
     28     private boolean mCalledDispatchCapturedPointerEvent;
     29     private boolean mCalledOnPointerCaptureChange;
     30 
     31     public PointerCaptureGroup(Context context) {
     32         super(context);
     33     }
     34 
     35     public PointerCaptureGroup(Context context, @Nullable AttributeSet attrs) {
     36         super(context, attrs);
     37     }
     38 
     39     public PointerCaptureGroup(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
     40         super(context, attrs, defStyleAttr);
     41     }
     42 
     43     public PointerCaptureGroup(Context context, @Nullable AttributeSet attrs, int defStyleAttr,
     44             int defStyleRes) {
     45         super(context, attrs, defStyleAttr, defStyleRes);
     46     }
     47 
     48     @Override
     49     public void dispatchPointerCaptureChanged(boolean hasCapture) {
     50         mCalledDispatchPointerCaptureChanged = true;
     51         super.dispatchPointerCaptureChanged(hasCapture);
     52     }
     53 
     54     @Override
     55     public void onPointerCaptureChange(boolean hasCapture) {
     56         mCalledOnPointerCaptureChange = true;
     57         super.onPointerCaptureChange(hasCapture);
     58     }
     59 
     60     @Override
     61     public boolean dispatchCapturedPointerEvent(MotionEvent event) {
     62         mCalledDispatchCapturedPointerEvent = true;
     63         return super.dispatchCapturedPointerEvent(event);
     64     }
     65 
     66     @Override
     67     public boolean onCapturedPointerEvent(MotionEvent event) {
     68         mCalledOnCapturedPointerEvent = true;
     69         return super.onCapturedPointerEvent(event);
     70     }
     71 
     72     void reset() {
     73         mCalledDispatchPointerCaptureChanged = false;
     74         mCalledDispatchCapturedPointerEvent = false;
     75         mCalledOnPointerCaptureChange = false;
     76         mCalledOnCapturedPointerEvent = false;
     77     }
     78 
     79     boolean hasCalledDispatchPointerCaptureChanged() {
     80         return mCalledDispatchPointerCaptureChanged;
     81     }
     82 
     83     boolean hasCalledOnCapturedPointerEvent() {
     84         return mCalledOnCapturedPointerEvent;
     85     }
     86 
     87     boolean hasCalledDispatchCapturedPointerEvent() {
     88         return mCalledDispatchCapturedPointerEvent;
     89     }
     90 
     91     boolean hasCalledOnPointerCaptureChange() {
     92         return mCalledOnPointerCaptureChange;
     93     }
     94 }
     95