Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package com.android.systemui.statusbar; |
| 18 | |
| 19 | import android.content.Context; |
| 20 | import android.util.AttributeSet; |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 21 | import android.view.View; |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 22 | import android.view.ViewGroup; |
| 23 | import android.widget.FrameLayout; |
| 24 | |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 25 | import com.android.systemui.R; |
| 26 | |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 27 | public 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 Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 36 | /** are we showing the "public" version */ |
| 37 | private boolean mShowingPublic; |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 38 | |
Jorim Jaggi | 251957d | 2014-04-09 04:24:09 +0200 | [diff] [blame^] | 39 | private LatestItemView mLatestItemView; |
| 40 | |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 41 | public ExpandableNotificationRow(Context context, AttributeSet attrs) { |
| 42 | super(context, attrs); |
| 43 | } |
| 44 | |
Jorim Jaggi | 251957d | 2014-04-09 04:24:09 +0200 | [diff] [blame^] | 45 | @Override |
| 46 | protected void onFinishInflate() { |
| 47 | super.onFinishInflate(); |
| 48 | mLatestItemView = (LatestItemView) findViewById(R.id.container); |
| 49 | } |
| 50 | |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 51 | 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 Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 92 | |
| 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 Jaggi | 251957d | 2014-04-09 04:24:09 +0200 | [diff] [blame^] | 104 | |
| 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 Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 119 | } |