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 | a32ab60 | 2014-06-11 15:06:01 +0200 | [diff] [blame] | 20 | import com.android.systemui.statusbar.ActivatableNotificationView; |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 21 | |
| 22 | import java.util.ArrayList; |
| 23 | |
| 24 | /** |
| 25 | * A global state to track all input states for the algorithm. |
| 26 | */ |
| 27 | public class AmbientState { |
| 28 | private ArrayList<View> mDraggedViews = new ArrayList<View>(); |
| 29 | private int mScrollY; |
| 30 | private boolean mDimmed; |
Selim Cinek | a32ab60 | 2014-06-11 15:06:01 +0200 | [diff] [blame] | 31 | private ActivatableNotificationView mActivatedChild; |
Selim Cinek | 8d9ff9c | 2014-05-12 15:13:04 +0200 | [diff] [blame] | 32 | private float mOverScrollTopAmount; |
| 33 | private float mOverScrollBottomAmount; |
Selim Cinek | c27437b | 2014-05-14 10:23:33 +0200 | [diff] [blame] | 34 | private int mSpeedBumpIndex = -1; |
Selim Cinek | f54090e | 2014-06-17 17:24:51 -0700 | [diff] [blame] | 35 | private float mScrimAmount; |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame^] | 36 | private boolean mDark; |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 37 | |
| 38 | public int getScrollY() { |
| 39 | return mScrollY; |
| 40 | } |
| 41 | |
| 42 | public void setScrollY(int scrollY) { |
| 43 | this.mScrollY = scrollY; |
| 44 | } |
| 45 | |
| 46 | public void onBeginDrag(View view) { |
| 47 | mDraggedViews.add(view); |
| 48 | } |
| 49 | |
| 50 | public void onDragFinished(View view) { |
| 51 | mDraggedViews.remove(view); |
| 52 | } |
| 53 | |
| 54 | public ArrayList<View> getDraggedViews() { |
| 55 | return mDraggedViews; |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * @param dimmed Whether we are in a dimmed state (on the lockscreen), where the backgrounds are |
| 60 | * translucent and everything is scaled back a bit. |
| 61 | */ |
| 62 | public void setDimmed(boolean dimmed) { |
| 63 | mDimmed = dimmed; |
| 64 | } |
| 65 | |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame^] | 66 | /** In dark mode, we draw as little as possible, assuming a black background */ |
| 67 | public void setDark(boolean dark) { |
| 68 | mDark = dark; |
| 69 | } |
| 70 | |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 71 | /** |
| 72 | * In dimmed mode, a child can be activated, which happens on the first tap of the double-tap |
| 73 | * interaction. This child is then scaled normally and its background is fully opaque. |
| 74 | */ |
Selim Cinek | a32ab60 | 2014-06-11 15:06:01 +0200 | [diff] [blame] | 75 | public void setActivatedChild(ActivatableNotificationView activatedChild) { |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 76 | mActivatedChild = activatedChild; |
| 77 | } |
| 78 | |
| 79 | public boolean isDimmed() { |
| 80 | return mDimmed; |
| 81 | } |
| 82 | |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame^] | 83 | public boolean isDark() { |
| 84 | return mDark; |
| 85 | } |
| 86 | |
Selim Cinek | a32ab60 | 2014-06-11 15:06:01 +0200 | [diff] [blame] | 87 | public ActivatableNotificationView getActivatedChild() { |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 88 | return mActivatedChild; |
| 89 | } |
Selim Cinek | 8d9ff9c | 2014-05-12 15:13:04 +0200 | [diff] [blame] | 90 | |
| 91 | public void setOverScrollAmount(float amount, boolean onTop) { |
| 92 | if (onTop) { |
| 93 | mOverScrollTopAmount = amount; |
| 94 | } else { |
| 95 | mOverScrollBottomAmount = amount; |
| 96 | } |
| 97 | } |
| 98 | |
Selim Cinek | f54090e | 2014-06-17 17:24:51 -0700 | [diff] [blame] | 99 | public void setScrimAmount(float scrimAmount) { |
| 100 | mScrimAmount = scrimAmount; |
| 101 | } |
| 102 | |
| 103 | public float getScrimAmount() { |
| 104 | return mScrimAmount; |
| 105 | } |
| 106 | |
Selim Cinek | 8d9ff9c | 2014-05-12 15:13:04 +0200 | [diff] [blame] | 107 | public float getOverScrollAmount(boolean top) { |
| 108 | return top ? mOverScrollTopAmount : mOverScrollBottomAmount; |
| 109 | } |
Selim Cinek | c27437b | 2014-05-14 10:23:33 +0200 | [diff] [blame] | 110 | |
| 111 | public int getSpeedBumpIndex() { |
| 112 | return mSpeedBumpIndex; |
| 113 | } |
| 114 | |
| 115 | public void setSpeedBumpIndex(int speedBumpIndex) { |
| 116 | mSpeedBumpIndex = speedBumpIndex; |
| 117 | } |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 118 | } |