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; 20 21 import com.android.systemui.statusbar.ActivatableNotificationView; 22 import com.android.systemui.statusbar.ExpandableNotificationRow; 23 import com.android.systemui.statusbar.policy.HeadsUpManager; 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; 34 private ActivatableNotificationView mActivatedChild; 35 private float mOverScrollTopAmount; 36 private float mOverScrollBottomAmount; 37 private int mSpeedBumpIndex = -1; 38 private boolean mDark; 39 private boolean mHideSensitive; 40 private HeadsUpManager mHeadsUpManager; 41 private float mStackTranslation; 42 private int mLayoutHeight; 43 private int mTopPadding; 44 private boolean mShadeExpanded; 45 private float mMaxHeadsUpTranslation; 46 private boolean mDismissAllInProgress; 47 getScrollY()48 public int getScrollY() { 49 return mScrollY; 50 } 51 setScrollY(int scrollY)52 public void setScrollY(int scrollY) { 53 this.mScrollY = scrollY; 54 } 55 onBeginDrag(View view)56 public void onBeginDrag(View view) { 57 mDraggedViews.add(view); 58 } 59 onDragFinished(View view)60 public void onDragFinished(View view) { 61 mDraggedViews.remove(view); 62 } 63 getDraggedViews()64 public ArrayList<View> getDraggedViews() { 65 return mDraggedViews; 66 } 67 68 /** 69 * @param dimmed Whether we are in a dimmed state (on the lockscreen), where the backgrounds are 70 * translucent and everything is scaled back a bit. 71 */ setDimmed(boolean dimmed)72 public void setDimmed(boolean dimmed) { 73 mDimmed = dimmed; 74 } 75 76 /** In dark mode, we draw as little as possible, assuming a black background */ setDark(boolean dark)77 public void setDark(boolean dark) { 78 mDark = dark; 79 } 80 setHideSensitive(boolean hideSensitive)81 public void setHideSensitive(boolean hideSensitive) { 82 mHideSensitive = hideSensitive; 83 } 84 85 /** 86 * In dimmed mode, a child can be activated, which happens on the first tap of the double-tap 87 * interaction. This child is then scaled normally and its background is fully opaque. 88 */ setActivatedChild(ActivatableNotificationView activatedChild)89 public void setActivatedChild(ActivatableNotificationView activatedChild) { 90 mActivatedChild = activatedChild; 91 } 92 isDimmed()93 public boolean isDimmed() { 94 return mDimmed; 95 } 96 isDark()97 public boolean isDark() { 98 return mDark; 99 } 100 isHideSensitive()101 public boolean isHideSensitive() { 102 return mHideSensitive; 103 } 104 getActivatedChild()105 public ActivatableNotificationView getActivatedChild() { 106 return mActivatedChild; 107 } 108 setOverScrollAmount(float amount, boolean onTop)109 public void setOverScrollAmount(float amount, boolean onTop) { 110 if (onTop) { 111 mOverScrollTopAmount = amount; 112 } else { 113 mOverScrollBottomAmount = amount; 114 } 115 } 116 getOverScrollAmount(boolean top)117 public float getOverScrollAmount(boolean top) { 118 return top ? mOverScrollTopAmount : mOverScrollBottomAmount; 119 } 120 getSpeedBumpIndex()121 public int getSpeedBumpIndex() { 122 return mSpeedBumpIndex; 123 } 124 setSpeedBumpIndex(int speedBumpIndex)125 public void setSpeedBumpIndex(int speedBumpIndex) { 126 mSpeedBumpIndex = speedBumpIndex; 127 } 128 setHeadsUpManager(HeadsUpManager headsUpManager)129 public void setHeadsUpManager(HeadsUpManager headsUpManager) { 130 mHeadsUpManager = headsUpManager; 131 } 132 getStackTranslation()133 public float getStackTranslation() { 134 return mStackTranslation; 135 } 136 setStackTranslation(float stackTranslation)137 public void setStackTranslation(float stackTranslation) { 138 mStackTranslation = stackTranslation; 139 } 140 getLayoutHeight()141 public int getLayoutHeight() { 142 return mLayoutHeight; 143 } 144 setLayoutHeight(int layoutHeight)145 public void setLayoutHeight(int layoutHeight) { 146 mLayoutHeight = layoutHeight; 147 } 148 getTopPadding()149 public float getTopPadding() { 150 return mTopPadding; 151 } 152 setTopPadding(int topPadding)153 public void setTopPadding(int topPadding) { 154 mTopPadding = topPadding; 155 } 156 getInnerHeight()157 public int getInnerHeight() { 158 return mLayoutHeight - mTopPadding - getTopHeadsUpPushIn(); 159 } 160 getTopHeadsUpPushIn()161 private int getTopHeadsUpPushIn() { 162 ExpandableNotificationRow topHeadsUpEntry = getTopHeadsUpEntry(); 163 return topHeadsUpEntry != null ? topHeadsUpEntry.getHeadsUpHeight() 164 - topHeadsUpEntry.getMinHeight(): 0; 165 } 166 isShadeExpanded()167 public boolean isShadeExpanded() { 168 return mShadeExpanded; 169 } 170 setShadeExpanded(boolean shadeExpanded)171 public void setShadeExpanded(boolean shadeExpanded) { 172 mShadeExpanded = shadeExpanded; 173 } 174 setMaxHeadsUpTranslation(float maxHeadsUpTranslation)175 public void setMaxHeadsUpTranslation(float maxHeadsUpTranslation) { 176 mMaxHeadsUpTranslation = maxHeadsUpTranslation; 177 } 178 getMaxHeadsUpTranslation()179 public float getMaxHeadsUpTranslation() { 180 return mMaxHeadsUpTranslation; 181 } 182 getTopHeadsUpEntry()183 public ExpandableNotificationRow getTopHeadsUpEntry() { 184 HeadsUpManager.HeadsUpEntry topEntry = mHeadsUpManager.getTopEntry(); 185 return topEntry == null ? null : topEntry.entry.row; 186 } 187 setDismissAllInProgress(boolean dismissAllInProgress)188 public void setDismissAllInProgress(boolean dismissAllInProgress) { 189 mDismissAllInProgress = dismissAllInProgress; 190 } 191 isDismissAllInProgress()192 public boolean isDismissAllInProgress() { 193 return mDismissAllInProgress; 194 } 195 } 196