1 /*
2  * Copyright 2018 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 androidx.preference;
18 
19 import static androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP;
20 
21 import android.content.Context;
22 import android.util.AttributeSet;
23 import android.widget.LinearLayout;
24 
25 import androidx.annotation.RestrictTo;
26 
27 /**
28  * Custom LinearLayout that does not propagate the pressed state down to its children.
29  * By default, the pressed state is propagated to all the children that are not clickable
30  * or long-clickable.
31  * @hide
32  */
33 @RestrictTo(LIBRARY_GROUP)
34 public class UnPressableLinearLayout extends LinearLayout {
UnPressableLinearLayout(Context context)35     public UnPressableLinearLayout(Context context) {
36         this(context, null);
37     }
38 
UnPressableLinearLayout(Context context, AttributeSet attrs)39     public UnPressableLinearLayout(Context context, AttributeSet attrs) {
40         super(context, attrs);
41     }
42 
43     @Override
dispatchSetPressed(boolean pressed)44     protected void dispatchSetPressed(boolean pressed) {
45         // Skip dispatching the pressed key state to the children so that they don't trigger any
46         // pressed state animation on their stateful drawables.
47     }
48 }
49