1 /* 2 * Copyright (C) 2011 Google Inc. 3 * Licensed to The Android Open Source Project. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 package com.android.mail.browse; 19 20 import android.content.Context; 21 import android.util.AttributeSet; 22 import android.view.View; 23 24 import com.android.mail.browse.ScrollNotifier.ScrollListener; 25 26 /** 27 * An overlay to sit on top of WebView, message headers, and snap header to display scrollbars. 28 * It has to sit on top of all other views that compose the conversation so that the scrollbars are 29 * not obscured. 30 * 31 */ 32 public class ScrollIndicatorsView extends View implements ScrollListener { 33 34 private ScrollNotifier mSource; 35 ScrollIndicatorsView(Context context)36 public ScrollIndicatorsView(Context context) { 37 super(context); 38 } 39 ScrollIndicatorsView(Context context, AttributeSet attrs)40 public ScrollIndicatorsView(Context context, AttributeSet attrs) { 41 super(context, attrs); 42 } 43 setSourceView(ScrollNotifier notifier)44 public void setSourceView(ScrollNotifier notifier) { 45 mSource = notifier; 46 mSource.addScrollListener(this); 47 } 48 49 @Override computeVerticalScrollRange()50 protected int computeVerticalScrollRange() { 51 return mSource.computeVerticalScrollRange(); 52 } 53 54 @Override computeVerticalScrollOffset()55 protected int computeVerticalScrollOffset() { 56 return mSource.computeVerticalScrollOffset(); 57 } 58 59 @Override computeVerticalScrollExtent()60 protected int computeVerticalScrollExtent() { 61 return mSource.computeVerticalScrollExtent(); 62 } 63 64 @Override computeHorizontalScrollRange()65 protected int computeHorizontalScrollRange() { 66 return mSource.computeHorizontalScrollRange(); 67 } 68 69 @Override computeHorizontalScrollOffset()70 protected int computeHorizontalScrollOffset() { 71 return mSource.computeHorizontalScrollOffset(); 72 } 73 74 @Override computeHorizontalScrollExtent()75 protected int computeHorizontalScrollExtent() { 76 return mSource.computeHorizontalScrollExtent(); 77 } 78 79 @Override onNotifierScroll(int top)80 public void onNotifierScroll(int top) { 81 awakenScrollBars(); 82 } 83 } 84