ExpandableNotificationRow.java revision a5e0f415d351ad1a9c0ffde8d93df91a2384591f
151c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren/* 251c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren * Copyright (C) 2013 The Android Open Source Project 351c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren * 451c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren * Licensed under the Apache License, Version 2.0 (the "License"); 551c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren * you may not use this file except in compliance with the License. 651c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren * You may obtain a copy of the License at 751c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren * 851c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren * http://www.apache.org/licenses/LICENSE-2.0 951c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren * 1051c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren * Unless required by applicable law or agreed to in writing, software 1151c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren * distributed under the License is distributed on an "AS IS" BASIS, 1251c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1351c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren * See the License for the specific language governing permissions and 1451c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren * limitations under the License. 1551c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren */ 1651c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren 1751c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wrenpackage com.android.systemui.statusbar; 1851c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren 1951c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wrenimport android.content.Context; 2051c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wrenimport android.util.AttributeSet; 21a5e0f415d351ad1a9c0ffde8d93df91a2384591fDan Sandlerimport android.view.View; 2251c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wrenimport android.view.ViewGroup; 2351c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wrenimport android.widget.FrameLayout; 2451c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren 25a5e0f415d351ad1a9c0ffde8d93df91a2384591fDan Sandlerimport com.android.systemui.R; 26a5e0f415d351ad1a9c0ffde8d93df91a2384591fDan Sandler 2751c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wrenpublic class ExpandableNotificationRow extends FrameLayout { 2851c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren private int mRowHeight; 2951c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren 3051c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren /** does this row contain layouts that can adapt to row expansion */ 3151c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren private boolean mExpandable; 3251c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren /** has the user manually expanded this row */ 3351c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren private boolean mUserExpanded; 3451c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren /** is the user touching this row */ 3551c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren private boolean mUserLocked; 36a5e0f415d351ad1a9c0ffde8d93df91a2384591fDan Sandler /** are we showing the "public" version */ 37a5e0f415d351ad1a9c0ffde8d93df91a2384591fDan Sandler private boolean mShowingPublic; 3851c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren 3951c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren public ExpandableNotificationRow(Context context, AttributeSet attrs) { 4051c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren super(context, attrs); 4151c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren } 4251c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren 4351c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren public int getRowHeight() { 4451c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren return mRowHeight; 4551c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren } 4651c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren 4751c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren public void setRowHeight(int rowHeight) { 4851c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren this.mRowHeight = rowHeight; 4951c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren } 5051c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren 5151c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren public boolean isExpandable() { 5251c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren return mExpandable; 5351c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren } 5451c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren 5551c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren public void setExpandable(boolean expandable) { 5651c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren mExpandable = expandable; 5751c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren } 5851c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren 5951c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren public boolean isUserExpanded() { 6051c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren return mUserExpanded; 6151c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren } 6251c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren 6351c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren public void setUserExpanded(boolean userExpanded) { 6451c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren mUserExpanded = userExpanded; 6551c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren } 6651c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren 6751c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren public boolean isUserLocked() { 6851c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren return mUserLocked; 6951c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren } 7051c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren 7151c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren public void setUserLocked(boolean userLocked) { 7251c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren mUserLocked = userLocked; 7351c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren } 7451c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren 7551c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren public void setExpanded(boolean expand) { 7651c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren ViewGroup.LayoutParams lp = getLayoutParams(); 7751c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren if (expand && mExpandable) { 7851c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren lp.height = ViewGroup.LayoutParams.WRAP_CONTENT; 7951c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren } else { 8051c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren lp.height = mRowHeight; 8151c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren } 8251c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren setLayoutParams(lp); 8351c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren } 84a5e0f415d351ad1a9c0ffde8d93df91a2384591fDan Sandler 85a5e0f415d351ad1a9c0ffde8d93df91a2384591fDan Sandler public void setShowingPublic(boolean show) { 86a5e0f415d351ad1a9c0ffde8d93df91a2384591fDan Sandler mShowingPublic = show; 87a5e0f415d351ad1a9c0ffde8d93df91a2384591fDan Sandler final ViewGroup publicLayout = (ViewGroup) findViewById(R.id.expandedPublic); 88a5e0f415d351ad1a9c0ffde8d93df91a2384591fDan Sandler 89a5e0f415d351ad1a9c0ffde8d93df91a2384591fDan Sandler // bail out if no public version 90a5e0f415d351ad1a9c0ffde8d93df91a2384591fDan Sandler if (publicLayout.getChildCount() == 0) return; 91a5e0f415d351ad1a9c0ffde8d93df91a2384591fDan Sandler 92a5e0f415d351ad1a9c0ffde8d93df91a2384591fDan Sandler // TODO: animation? 93a5e0f415d351ad1a9c0ffde8d93df91a2384591fDan Sandler publicLayout.setVisibility(show ? View.VISIBLE : View.GONE); 94a5e0f415d351ad1a9c0ffde8d93df91a2384591fDan Sandler findViewById(R.id.expanded).setVisibility(show ? View.GONE : View.VISIBLE); 95a5e0f415d351ad1a9c0ffde8d93df91a2384591fDan Sandler } 9651c7510e493680b4aca1ed7695b35c52d2cd63ffChris Wren} 97