Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 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.stack; |
| 18 | |
| 19 | import android.view.View; |
Selim Cinek | a59ecc3 | 2015-04-07 10:51:49 -0700 | [diff] [blame] | 20 | |
Selim Cinek | a32ab60 | 2014-06-11 15:06:01 +0200 | [diff] [blame] | 21 | import com.android.systemui.statusbar.ActivatableNotificationView; |
Selim Cinek | a59ecc3 | 2015-04-07 10:51:49 -0700 | [diff] [blame] | 22 | import com.android.systemui.statusbar.ExpandableNotificationRow; |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 23 | import com.android.systemui.statusbar.policy.HeadsUpManager; |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 24 | |
| 25 | import java.util.ArrayList; |
| 26 | |
| 27 | /** |
| 28 | * A global state to track all input states for the algorithm. |
| 29 | */ |
| 30 | public class AmbientState { |
| 31 | private ArrayList<View> mDraggedViews = new ArrayList<View>(); |
| 32 | private int mScrollY; |
| 33 | private boolean mDimmed; |
Selim Cinek | a32ab60 | 2014-06-11 15:06:01 +0200 | [diff] [blame] | 34 | private ActivatableNotificationView mActivatedChild; |
Selim Cinek | 8d9ff9c | 2014-05-12 15:13:04 +0200 | [diff] [blame] | 35 | private float mOverScrollTopAmount; |
| 36 | private float mOverScrollBottomAmount; |
Selim Cinek | c27437b | 2014-05-14 10:23:33 +0200 | [diff] [blame] | 37 | private int mSpeedBumpIndex = -1; |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 38 | private boolean mDark; |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 39 | private boolean mHideSensitive; |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 40 | private HeadsUpManager mHeadsUpManager; |
Selim Cinek | a59ecc3 | 2015-04-07 10:51:49 -0700 | [diff] [blame] | 41 | private float mStackTranslation; |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 42 | private int mLayoutHeight; |
| 43 | private int mTopPadding; |
| 44 | private boolean mShadeExpanded; |
| 45 | private float mMaxHeadsUpTranslation; |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 46 | |
| 47 | public int getScrollY() { |
| 48 | return mScrollY; |
| 49 | } |
| 50 | |
| 51 | public void setScrollY(int scrollY) { |
| 52 | this.mScrollY = scrollY; |
| 53 | } |
| 54 | |
| 55 | public void onBeginDrag(View view) { |
| 56 | mDraggedViews.add(view); |
| 57 | } |
| 58 | |
| 59 | public void onDragFinished(View view) { |
| 60 | mDraggedViews.remove(view); |
| 61 | } |
| 62 | |
| 63 | public ArrayList<View> getDraggedViews() { |
| 64 | return mDraggedViews; |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * @param dimmed Whether we are in a dimmed state (on the lockscreen), where the backgrounds are |
| 69 | * translucent and everything is scaled back a bit. |
| 70 | */ |
| 71 | public void setDimmed(boolean dimmed) { |
| 72 | mDimmed = dimmed; |
| 73 | } |
| 74 | |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 75 | /** In dark mode, we draw as little as possible, assuming a black background */ |
| 76 | public void setDark(boolean dark) { |
| 77 | mDark = dark; |
| 78 | } |
| 79 | |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 80 | public void setHideSensitive(boolean hideSensitive) { |
| 81 | mHideSensitive = hideSensitive; |
| 82 | } |
| 83 | |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 84 | /** |
| 85 | * In dimmed mode, a child can be activated, which happens on the first tap of the double-tap |
| 86 | * interaction. This child is then scaled normally and its background is fully opaque. |
| 87 | */ |
Selim Cinek | a32ab60 | 2014-06-11 15:06:01 +0200 | [diff] [blame] | 88 | public void setActivatedChild(ActivatableNotificationView activatedChild) { |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 89 | mActivatedChild = activatedChild; |
| 90 | } |
| 91 | |
| 92 | public boolean isDimmed() { |
| 93 | return mDimmed; |
| 94 | } |
| 95 | |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 96 | public boolean isDark() { |
| 97 | return mDark; |
| 98 | } |
| 99 | |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 100 | public boolean isHideSensitive() { |
| 101 | return mHideSensitive; |
| 102 | } |
| 103 | |
Selim Cinek | a32ab60 | 2014-06-11 15:06:01 +0200 | [diff] [blame] | 104 | public ActivatableNotificationView getActivatedChild() { |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 105 | return mActivatedChild; |
| 106 | } |
Selim Cinek | 8d9ff9c | 2014-05-12 15:13:04 +0200 | [diff] [blame] | 107 | |
| 108 | public void setOverScrollAmount(float amount, boolean onTop) { |
| 109 | if (onTop) { |
| 110 | mOverScrollTopAmount = amount; |
| 111 | } else { |
| 112 | mOverScrollBottomAmount = amount; |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | public float getOverScrollAmount(boolean top) { |
| 117 | return top ? mOverScrollTopAmount : mOverScrollBottomAmount; |
| 118 | } |
Selim Cinek | c27437b | 2014-05-14 10:23:33 +0200 | [diff] [blame] | 119 | |
| 120 | public int getSpeedBumpIndex() { |
| 121 | return mSpeedBumpIndex; |
| 122 | } |
| 123 | |
| 124 | public void setSpeedBumpIndex(int speedBumpIndex) { |
| 125 | mSpeedBumpIndex = speedBumpIndex; |
| 126 | } |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 127 | |
| 128 | public void setHeadsUpManager(HeadsUpManager headsUpManager) { |
| 129 | mHeadsUpManager = headsUpManager; |
| 130 | } |
| 131 | |
Selim Cinek | a59ecc3 | 2015-04-07 10:51:49 -0700 | [diff] [blame] | 132 | public float getStackTranslation() { |
| 133 | return mStackTranslation; |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 134 | } |
| 135 | |
Selim Cinek | a59ecc3 | 2015-04-07 10:51:49 -0700 | [diff] [blame] | 136 | public void setStackTranslation(float stackTranslation) { |
| 137 | mStackTranslation = stackTranslation; |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 138 | } |
| 139 | |
| 140 | public int getLayoutHeight() { |
| 141 | return mLayoutHeight; |
| 142 | } |
| 143 | |
| 144 | public void setLayoutHeight(int layoutHeight) { |
| 145 | mLayoutHeight = layoutHeight; |
| 146 | } |
| 147 | |
Selim Cinek | a59ecc3 | 2015-04-07 10:51:49 -0700 | [diff] [blame] | 148 | public float getTopPadding() { |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 149 | return mTopPadding; |
| 150 | } |
| 151 | |
| 152 | public void setTopPadding(int topPadding) { |
| 153 | mTopPadding = topPadding; |
| 154 | } |
| 155 | |
| 156 | public int getInnerHeight() { |
Selim Cinek | a59ecc3 | 2015-04-07 10:51:49 -0700 | [diff] [blame] | 157 | return mLayoutHeight - mTopPadding - getTopHeadsUpPushIn(); |
| 158 | } |
| 159 | |
| 160 | private int getTopHeadsUpPushIn() { |
| 161 | ExpandableNotificationRow topHeadsUpEntry = getTopHeadsUpEntry(); |
| 162 | return topHeadsUpEntry != null ? topHeadsUpEntry.getHeadsUpHeight() |
| 163 | - topHeadsUpEntry.getMinHeight(): 0; |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 164 | } |
| 165 | |
| 166 | public boolean isShadeExpanded() { |
| 167 | return mShadeExpanded; |
| 168 | } |
| 169 | |
| 170 | public void setShadeExpanded(boolean shadeExpanded) { |
| 171 | mShadeExpanded = shadeExpanded; |
| 172 | } |
| 173 | |
| 174 | public void setMaxHeadsUpTranslation(float maxHeadsUpTranslation) { |
| 175 | mMaxHeadsUpTranslation = maxHeadsUpTranslation; |
| 176 | } |
| 177 | |
| 178 | public float getMaxHeadsUpTranslation() { |
| 179 | return mMaxHeadsUpTranslation; |
| 180 | } |
Selim Cinek | a59ecc3 | 2015-04-07 10:51:49 -0700 | [diff] [blame] | 181 | |
| 182 | public ExpandableNotificationRow getTopHeadsUpEntry() { |
| 183 | HeadsUpManager.HeadsUpEntry topEntry = mHeadsUpManager.getTopEntry(); |
| 184 | return topEntry == null ? null : topEntry.entry.row; |
| 185 | } |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 186 | } |