diff options
author | Adrian Roos <roosa@google.com> | 2014-06-30 15:11:53 +0200 |
---|---|---|
committer | Adrian Roos <roosa@google.com> | 2014-07-02 12:33:36 +0000 |
commit | b83777ba5c12295224cd566bba59a44b8860e449 (patch) | |
tree | 82c04959eb37d4d72114fa1d9ab315610c2e7be0 /packages/SystemUI/src/com/android/systemui/qs | |
parent | f29131f7013dc0d6994556b95e74db608c89beb8 (diff) | |
download | frameworks_base-b83777ba5c12295224cd566bba59a44b8860e449.zip frameworks_base-b83777ba5c12295224cd566bba59a44b8860e449.tar.gz frameworks_base-b83777ba5c12295224cd566bba59a44b8860e449.tar.bz2 |
Add flashlight to quick settings
Bug: 15934851
Change-Id: I86f61fa11fe64e76adb032391ce7e7170f59549d
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/qs')
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/qs/QSTile.java | 2 | ||||
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/qs/tiles/FlashlightTile.java | 80 |
2 files changed, 82 insertions, 0 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSTile.java b/packages/SystemUI/src/com/android/systemui/qs/QSTile.java index 786cd9e..ba350e5 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSTile.java @@ -30,6 +30,7 @@ import com.android.systemui.R; import com.android.systemui.qs.QSTile.State; import com.android.systemui.statusbar.policy.BluetoothController; import com.android.systemui.statusbar.policy.CastController; +import com.android.systemui.statusbar.policy.FlashlightController; import com.android.systemui.statusbar.policy.Listenable; import com.android.systemui.statusbar.policy.LocationController; import com.android.systemui.statusbar.policy.NetworkController; @@ -221,6 +222,7 @@ public abstract class QSTile<TState extends State> implements Listenable { TetheringController getTetheringController(); CastController getCastController(); VolumeComponent getVolumeComponent(); + FlashlightController getFlashlightController(); } public static class State { diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/FlashlightTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/FlashlightTile.java new file mode 100644 index 0000000..b610cf3 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/FlashlightTile.java @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +package com.android.systemui.qs.tiles; + +import com.android.systemui.R; +import com.android.systemui.qs.QSTile; +import com.android.systemui.qs.SecureSetting; +import com.android.systemui.statusbar.policy.FlashlightController; + +import android.os.Handler; +import android.os.Looper; +import android.provider.Settings.Secure; + +/** Quick settings tile: Control flashlight **/ +public class FlashlightTile extends QSTile<QSTile.BooleanState> implements + FlashlightController.FlashlightListener { + + private final FlashlightController mFlashlightController; + + public FlashlightTile(Host host) { + super(host); + mFlashlightController = host.getFlashlightController(); + mFlashlightController.addListener(this); + } + + @Override + protected BooleanState newTileState() { + return new BooleanState(); + } + + @Override + public void setListening(boolean listening) { + } + + @Override + protected void handleUserSwitch(int newUserId) { + } + + @Override + protected void handleClick() { + boolean newState = !mState.value; + mFlashlightController.setFlashlight(newState); + refreshState(newState); + } + + @Override + protected void handleUpdateState(BooleanState state, Object arg) { + if (arg instanceof Boolean) { + state.value = (Boolean) arg; + } + state.visible = mFlashlightController.isAvailable(); + state.label = mHost.getContext().getString(R.string.quick_settings_flashlight_label); + state.iconId = state.value + ? R.drawable.ic_qs_flashlight_on : R.drawable.ic_qs_flashlight_off; + } + + @Override + public void onFlashlightOff() { + refreshState(false); + } + + @Override + public void onFlashlightError() { + refreshState(false); + } +} |