blob: c9ca55b4ff6685c4fad457257d3dbb44ccb0809b [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
Jorim Jaggi251957d2014-04-09 04:24:09 +020039 private LatestItemView mLatestItemView;
40
Chris Wren51c75102013-07-16 20:49:17 -040041 public ExpandableNotificationRow(Context context, AttributeSet attrs) {
42 super(context, attrs);
43 }
44
Jorim Jaggi251957d2014-04-09 04:24:09 +020045 @Override
46 protected void onFinishInflate() {
47 super.onFinishInflate();
48 mLatestItemView = (LatestItemView) findViewById(R.id.container);
49 }
50
Chris Wren51c75102013-07-16 20:49:17 -040051 public int getRowHeight() {
52 return mRowHeight;
53 }
54
55 public void setRowHeight(int rowHeight) {
56 this.mRowHeight = rowHeight;
57 }
58
59 public boolean isExpandable() {
60 return mExpandable;
61 }
62
63 public void setExpandable(boolean expandable) {
64 mExpandable = expandable;
65 }
66
67 public boolean isUserExpanded() {
68 return mUserExpanded;
69 }
70
71 public void setUserExpanded(boolean userExpanded) {
72 mUserExpanded = userExpanded;
73 }
74
75 public boolean isUserLocked() {
76 return mUserLocked;
77 }
78
79 public void setUserLocked(boolean userLocked) {
80 mUserLocked = userLocked;
81 }
82
83 public void setExpanded(boolean expand) {
84 ViewGroup.LayoutParams lp = getLayoutParams();
85 if (expand && mExpandable) {
86 lp.height = ViewGroup.LayoutParams.WRAP_CONTENT;
87 } else {
88 lp.height = mRowHeight;
89 }
90 setLayoutParams(lp);
91 }
Dan Sandlera5e0f412014-01-23 15:11:54 -050092
93 public void setShowingPublic(boolean show) {
94 mShowingPublic = show;
95 final ViewGroup publicLayout = (ViewGroup) findViewById(R.id.expandedPublic);
96
97 // bail out if no public version
98 if (publicLayout.getChildCount() == 0) return;
99
100 // TODO: animation?
101 publicLayout.setVisibility(show ? View.VISIBLE : View.GONE);
102 findViewById(R.id.expanded).setVisibility(show ? View.GONE : View.VISIBLE);
103 }
Jorim Jaggi251957d2014-04-09 04:24:09 +0200104
105 /**
106 * Sets the notification as dimmed, meaning that it will appear in a more gray variant.
107 */
108 public void setDimmed(boolean dimmed) {
109 mLatestItemView.setDimmed(dimmed);
110 }
111
112 /**
113 * Sets the notification as locked. In the locked state, the first tap will produce a quantum
114 * ripple to make the notification brighter and only the second tap will cause a click.
115 */
116 public void setLocked(boolean locked) {
117 mLatestItemView.setLocked(locked);
118 }
Chris Wren51c75102013-07-16 20:49:17 -0400119}