Home | History | Annotate | Download | only in stack
      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 import com.android.systemui.statusbar.ActivatableNotificationView;
     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;
     31     private ActivatableNotificationView mActivatedChild;
     32     private float mOverScrollTopAmount;
     33     private float mOverScrollBottomAmount;
     34     private int mSpeedBumpIndex = -1;
     35     private boolean mDark;
     36     private boolean mHideSensitive;
     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 
     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 
     71     public void setHideSensitive(boolean hideSensitive) {
     72         mHideSensitive = hideSensitive;
     73     }
     74 
     75     /**
     76      * In dimmed mode, a child can be activated, which happens on the first tap of the double-tap
     77      * interaction. This child is then scaled normally and its background is fully opaque.
     78      */
     79     public void setActivatedChild(ActivatableNotificationView activatedChild) {
     80         mActivatedChild = activatedChild;
     81     }
     82 
     83     public boolean isDimmed() {
     84         return mDimmed;
     85     }
     86 
     87     public boolean isDark() {
     88         return mDark;
     89     }
     90 
     91     public boolean isHideSensitive() {
     92         return mHideSensitive;
     93     }
     94 
     95     public ActivatableNotificationView getActivatedChild() {
     96         return mActivatedChild;
     97     }
     98 
     99     public void setOverScrollAmount(float amount, boolean onTop) {
    100         if (onTop) {
    101             mOverScrollTopAmount = amount;
    102         } else {
    103             mOverScrollBottomAmount = amount;
    104         }
    105     }
    106 
    107     public float getOverScrollAmount(boolean top) {
    108         return top ? mOverScrollTopAmount : mOverScrollBottomAmount;
    109     }
    110 
    111     public int getSpeedBumpIndex() {
    112         return mSpeedBumpIndex;
    113     }
    114 
    115     public void setSpeedBumpIndex(int speedBumpIndex) {
    116         mSpeedBumpIndex = speedBumpIndex;
    117     }
    118 }
    119