blob: b3d8688d4b42ff98eed33e3b78a3d95dccb84292 [file] [log] [blame]
Chris Wren51c75102013-07-16 20:49:17 -04001/*
2 * Copyright (C) 2013 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;
18
19import android.content.Context;
20import android.util.AttributeSet;
Dan Sandlera5e0f412014-01-23 15:11:54 -050021import android.view.View;
Chris Wren51c75102013-07-16 20:49:17 -040022import android.view.ViewGroup;
23import android.widget.FrameLayout;
24
Dan Sandlera5e0f412014-01-23 15:11:54 -050025import com.android.systemui.R;
26
Chris Wren51c75102013-07-16 20:49:17 -040027public class ExpandableNotificationRow extends FrameLayout {
28 private int mRowHeight;
29
30 /** does this row contain layouts that can adapt to row expansion */
31 private boolean mExpandable;
32 /** has the user manually expanded this row */
33 private boolean mUserExpanded;
34 /** is the user touching this row */
35 private boolean mUserLocked;
Dan Sandlera5e0f412014-01-23 15:11:54 -050036 /** are we showing the "public" version */
37 private boolean mShowingPublic;
Chris Wren51c75102013-07-16 20:49:17 -040038
39 public ExpandableNotificationRow(Context context, AttributeSet attrs) {
40 super(context, attrs);
41 }
42
43 public int getRowHeight() {
44 return mRowHeight;
45 }
46
47 public void setRowHeight(int rowHeight) {
48 this.mRowHeight = rowHeight;
49 }
50
51 public boolean isExpandable() {
52 return mExpandable;
53 }
54
55 public void setExpandable(boolean expandable) {
56 mExpandable = expandable;
57 }
58
59 public boolean isUserExpanded() {
60 return mUserExpanded;
61 }
62
63 public void setUserExpanded(boolean userExpanded) {
64 mUserExpanded = userExpanded;
65 }
66
67 public boolean isUserLocked() {
68 return mUserLocked;
69 }
70
71 public void setUserLocked(boolean userLocked) {
72 mUserLocked = userLocked;
73 }
74
75 public void setExpanded(boolean expand) {
76 ViewGroup.LayoutParams lp = getLayoutParams();
77 if (expand && mExpandable) {
78 lp.height = ViewGroup.LayoutParams.WRAP_CONTENT;
79 } else {
80 lp.height = mRowHeight;
81 }
82 setLayoutParams(lp);
83 }
Dan Sandlera5e0f412014-01-23 15:11:54 -050084
85 public void setShowingPublic(boolean show) {
86 mShowingPublic = show;
87 final ViewGroup publicLayout = (ViewGroup) findViewById(R.id.expandedPublic);
88
89 // bail out if no public version
90 if (publicLayout.getChildCount() == 0) return;
91
92 // TODO: animation?
93 publicLayout.setVisibility(show ? View.VISIBLE : View.GONE);
94 findViewById(R.id.expanded).setVisibility(show ? View.GONE : View.VISIBLE);
95 }
Chris Wren51c75102013-07-16 20:49:17 -040096}