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 | |
| 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 Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 84 | |
| 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 Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 96 | } |