1 /*
2  * Copyright (C) 2014 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 com.android.systemui.statusbar.phone;
18 
19 import android.content.Context;
20 import android.text.TextUtils;
21 import android.util.AttributeSet;
22 import android.view.accessibility.AccessibilityEvent;
23 import android.view.accessibility.AccessibilityNodeInfo;
24 import android.widget.Button;
25 import android.widget.FrameLayout;
26 
27 import com.android.systemui.R;
28 
29 /**
30  * Container for image of the multi user switcher (tappable).
31  */
32 public class MultiUserSwitch extends FrameLayout {
MultiUserSwitch(Context context, AttributeSet attrs)33     public MultiUserSwitch(Context context, AttributeSet attrs) {
34         super(context, attrs);
35     }
36 
refreshContentDescription(String currentUser)37     void refreshContentDescription(String currentUser) {
38         String text = null;
39 
40         if (!TextUtils.isEmpty(currentUser)) {
41             text = mContext.getString(
42                     R.string.accessibility_quick_settings_user,
43                     currentUser);
44         }
45 
46         if (!TextUtils.equals(getContentDescription(), text)) {
47             setContentDescription(text);
48         }
49     }
50 
51     @Override
onInitializeAccessibilityEvent(AccessibilityEvent event)52     public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
53         super.onInitializeAccessibilityEvent(event);
54         event.setClassName(Button.class.getName());
55     }
56 
57     @Override
onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info)58     public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
59         super.onInitializeAccessibilityNodeInfo(info);
60         info.setClassName(Button.class.getName());
61     }
62 
63     @Override
hasOverlappingRendering()64     public boolean hasOverlappingRendering() {
65         return false;
66     }
67 }
68