blob: 735ee254563b156bbe20cba62cc00f202f413f81 [file] [log] [blame]
Daniel Sandler50a53132012-10-24 15:02:27 -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
Daniel Sandler9ff63782012-05-03 23:16:42 -040017package com.android.systemui.statusbar;
18
19import android.content.Context;
20import android.util.AttributeSet;
21import android.widget.CompoundButton;
22
23import com.android.systemui.statusbar.policy.AutoRotateController;
24
Jeff Brown207673cd2012-06-05 17:47:11 -070025public class RotationToggle extends CompoundButton
26 implements AutoRotateController.RotationLockCallbacks {
27 private AutoRotateController mRotater;
Daniel Sandler9ff63782012-05-03 23:16:42 -040028
29 public RotationToggle(Context context) {
30 super(context);
Daniel Sandler9ff63782012-05-03 23:16:42 -040031 }
32
33 public RotationToggle(Context context, AttributeSet attrs) {
34 super(context, attrs);
Daniel Sandler9ff63782012-05-03 23:16:42 -040035 }
36
37 public RotationToggle(Context context, AttributeSet attrs, int defStyle) {
38 super(context, attrs, defStyle);
Daniel Sandler9ff63782012-05-03 23:16:42 -040039 }
40
Jeff Brown207673cd2012-06-05 17:47:11 -070041 @Override
42 protected void onAttachedToWindow() {
43 super.onAttachedToWindow();
44 mRotater = new AutoRotateController(getContext(), this, this);
45 }
46
47 @Override
48 protected void onDetachedFromWindow() {
49 super.onDetachedFromWindow();
50 if (mRotater != null) {
51 mRotater.release();
52 mRotater = null;
53 }
54 }
55
56 @Override
57 public void setRotationLockControlVisibility(boolean show) {
58 setVisibility(show ? VISIBLE : GONE);
59 }
Daniel Sandler9ff63782012-05-03 23:16:42 -040060}