blob: 8a2f8d68476932a26e1774fba4d47100c09ba940 [file] [log] [blame]
Daniel Sandlere5f7ec02012-10-03 10:40:00 -04001/*
2 * Copyright (C) 2012 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
17package com.android.systemui.statusbar.phone;
18
19import android.content.Context;
20import android.util.AttributeSet;
21import android.view.MotionEvent;
22import android.view.View;
23import android.widget.ScrollView;
24
25public class QuickSettingsScrollView extends ScrollView {
26
27 public QuickSettingsScrollView(Context context) {
28 super(context);
29 }
30
31 public QuickSettingsScrollView(Context context, AttributeSet attrs) {
32 super(context, attrs);
33 }
34
35 public QuickSettingsScrollView(Context context, AttributeSet attrs, int defStyle) {
36 super(context, attrs, defStyle);
37 }
38
39 // Y U NO PROTECTED
40 private int getScrollRange() {
41 int scrollRange = 0;
42 if (getChildCount() > 0) {
43 View child = getChildAt(0);
44 scrollRange = Math.max(0,
45 child.getHeight() - (getHeight() - mPaddingBottom - mPaddingTop));
46 }
47 return scrollRange;
48 }
49
50 @Override
51 public boolean onTouchEvent(MotionEvent ev) {
52 final int range = getScrollRange();
53 if (range == 0) {
54 return false;
55 }
56
57 return super.onTouchEvent(ev);
58 }
59}