blob: 7c6e47cf257aa4b1afcb73657395727d9a35c68d [file] [log] [blame]
Jorim Jaggid7daab72014-05-06 22:22:20 +02001/*
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
17package com.android.systemui.statusbar.phone;
18
19import android.content.Context;
Jorim Jaggibc976e32014-07-25 16:42:34 +020020import android.graphics.Canvas;
Jorim Jaggid7daab72014-05-06 22:22:20 +020021import android.graphics.Rect;
22import android.util.AttributeSet;
Jorim Jaggibc976e32014-07-25 16:42:34 +020023import android.view.View;
24import android.view.ViewStub;
Jorim Jaggid7daab72014-05-06 22:22:20 +020025import android.widget.FrameLayout;
26
Jorim Jaggibc976e32014-07-25 16:42:34 +020027import com.android.systemui.R;
28
Jorim Jaggid7daab72014-05-06 22:22:20 +020029/**
30 * The container with notification stack scroller and quick settings inside.
31 */
Jorim Jaggibc976e32014-07-25 16:42:34 +020032public class NotificationsQuickSettingsContainer extends FrameLayout
33 implements ViewStub.OnInflateListener {
34
35 private View mScrollView;
36 private View mUserSwitcher;
37 private View mStackScroller;
38 private boolean mInflated;
Jorim Jaggid7daab72014-05-06 22:22:20 +020039
40 public NotificationsQuickSettingsContainer(Context context, AttributeSet attrs) {
41 super(context, attrs);
42 }
43
44 @Override
Jorim Jaggibc976e32014-07-25 16:42:34 +020045 protected void onFinishInflate() {
46 super.onFinishInflate();
47 mScrollView = findViewById(R.id.scroll_view);
48 mStackScroller = findViewById(R.id.notification_stack_scroller);
49 ViewStub userSwitcher = (ViewStub) findViewById(R.id.keyguard_user_switcher);
50 userSwitcher.setOnInflateListener(this);
51 mUserSwitcher = userSwitcher;
52 }
53
54 @Override
Jorim Jaggid7daab72014-05-06 22:22:20 +020055 protected boolean fitSystemWindows(Rect insets) {
56 setPadding(0, 0, 0, insets.bottom);
57 insets.bottom = 0;
58 return true;
59 }
Jorim Jaggibc976e32014-07-25 16:42:34 +020060
61 @Override
62 protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
63 boolean userSwitcherVisible = mInflated && mUserSwitcher.getVisibility() == View.VISIBLE;
64
65 // Invert the order of the scroll view and user switcher such that the notifications receive
66 // touches first but the panel gets drawn above.
67 if (child == mScrollView) {
68 return super.drawChild(canvas, mStackScroller, drawingTime);
69 } else if (child == mStackScroller) {
70 return super.drawChild(canvas, userSwitcherVisible ? mUserSwitcher : mScrollView,
71 drawingTime);
72 } else if (child == mUserSwitcher) {
73 return super.drawChild(canvas, userSwitcherVisible ? mScrollView : mUserSwitcher,
74 drawingTime);
75 } else {
76 return super.drawChild(canvas, child, drawingTime);
77 }
78 }
79
80 @Override
81 public void onInflate(ViewStub stub, View inflated) {
82 if (stub == mUserSwitcher) {
83 mUserSwitcher = inflated;
84 mInflated = true;
85 }
86 }
Jorim Jaggid7daab72014-05-06 22:22:20 +020087}