Loading core/java/android/provider/Settings.java +1 −0 Original line number Diff line number Diff line Loading @@ -2358,6 +2358,7 @@ public final class Settings { public static final String WIDGET_BUTTONS_TABLET = "expanded_widget_buttons_tablet"; /** * Navigation controls to Use * * @hide Loading packages/SystemUI/res/layout/system_bar_settings_view.xml +108 −18 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- * Copyright (C) 2010 The Android Open Source Project * This code has been modified. Portions copyright (C) 2012 ParanoidAndroid Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. Loading @@ -15,6 +16,11 @@ * limitations under the License. --> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="match_parent" android:layout_width="match_parent"> <com.android.systemui.statusbar.tablet.SettingsView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:systemui="http://schemas.android.com/apk/res/com.android.systemui" Loading @@ -23,75 +29,158 @@ android:orientation="vertical" > <!-- Airplane mode --> <!-- Toggle 1 --> <LinearLayout android:id="@+id/airplane" android:id="@+id/toggle_1" style="@style/StatusBarPanelSettingsRow" > <ImageView android:id="@+id/airplane_icon" android:id="@+id/toggle_1_icon" style="@style/StatusBarPanelSettingsIcon" android:src="@drawable/ic_sysbar_airplane_on" /> <TextView android:id="@+id/airplane_label" android:id="@+id/toggle_1_label" style="@style/StatusBarPanelSettingsContents" android:text="@string/status_bar_settings_airplane" /> <Switch android:id="@+id/airplane_checkbox" android:id="@+id/toggle_1_checkbox" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_marginRight="5dp" /> </LinearLayout> <View style="@style/StatusBarPanelSettingsPanelSeparator" /> <!-- Network --> <View android:id="@+id/rotate_separator" style="@style/StatusBarPanelSettingsPanelSeparator" /> <!-- Toggle 2 --> <LinearLayout android:id="@+id/network" android:id="@+id/toggle_2" style="@style/StatusBarPanelSettingsRow" > <ImageView android:id="@+id/network_icon" android:id="@+id/toggle_2_icon" style="@style/StatusBarPanelSettingsIcon" android:src="@drawable/ic_sysbar_wifi_on" /> <TextView android:id="@+id/network_label" android:id="@+id/toggle_2_label" style="@style/StatusBarPanelSettingsContents" android:text="@string/status_bar_settings_wifi_button" /> <Switch android:id="@+id/toggle_2_checkbox" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_marginRight="5dp" /> </LinearLayout> <View style="@style/StatusBarPanelSettingsPanelSeparator" /> <!-- Toggle 3 --> <LinearLayout android:id="@+id/toggle_3" style="@style/StatusBarPanelSettingsRow" > <ImageView android:id="@+id/toggle_3_icon" style="@style/StatusBarPanelSettingsIcon" android:src="@drawable/stat_sys_data_bluetooth" /> <TextView android:id="@+id/toggle_3_label" style="@style/StatusBarPanelSettingsContents" android:text="@string/status_bar_settings_bluetooth_button" /> <Switch android:id="@+id/toggle_3_checkbox" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_marginRight="5dp" /> </LinearLayout> <View style="@style/StatusBarPanelSettingsPanelSeparator" /> <!-- Rotation lock --> <!-- Toggle 4 --> <LinearLayout android:id="@+id/rotate" android:id="@+id/toggle_4" style="@style/StatusBarPanelSettingsRow" > <ImageView android:id="@+id/rotate_icon" android:id="@+id/toggle_4_icon" style="@style/StatusBarPanelSettingsIcon" android:src="@drawable/ic_sysbar_rotate_on" /> <TextView android:id="@+id/rotate_label" android:id="@+id/toggle_4_label" style="@style/StatusBarPanelSettingsContents" android:text="@string/status_bar_settings_auto_rotation" /> <Switch android:id="@+id/rotate_checkbox" android:id="@+id/toggle_4_checkbox" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_marginRight="5dp" /> </LinearLayout> <View android:id="@+id/rotate_separator" style="@style/StatusBarPanelSettingsPanelSeparator" /> <View style="@style/StatusBarPanelSettingsPanelSeparator" /> <!-- Toggle 5 --> <LinearLayout android:id="@+id/toggle_5" style="@style/StatusBarPanelSettingsRow" > <ImageView android:id="@+id/toggle_5_icon" style="@style/StatusBarPanelSettingsIcon" android:src="@drawable/stat_gps_on" /> <TextView android:id="@+id/toggle_5_label" style="@style/StatusBarPanelSettingsContents" android:text="@string/status_bar_settings_location" /> <Switch android:id="@+id/toggle_5_checkbox" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_marginRight="5dp" /> </LinearLayout> <View style="@style/StatusBarPanelSettingsPanelSeparator" /> <!-- Toggle 6 --> <LinearLayout android:id="@+id/toggle_6" style="@style/StatusBarPanelSettingsRow" > <ImageView android:id="@+id/toggle_6_icon" style="@style/StatusBarPanelSettingsIcon" android:src="@drawable/stat_flashlight_on" /> <TextView android:id="@+id/toggle_6_label" style="@style/StatusBarPanelSettingsContents" android:text="@string/status_bar_settings_flashlight" /> <Switch android:id="@+id/toggle_6_checkbox" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_marginRight="5dp" /> </LinearLayout> <View style="@style/StatusBarPanelSettingsPanelSeparator" /> <!-- Brightness --> <LinearLayout style="@style/StatusBarPanelSettingsRow" > Loading Loading @@ -155,3 +244,4 @@ </com.android.systemui.statusbar.tablet.SettingsView> </ScrollView> packages/SystemUI/res/values/strings.xml +18 −0 Original line number Diff line number Diff line Loading @@ -96,9 +96,27 @@ <!-- Name of the button that links to the Wifi settings screen. [CHAR LIMIT=NONE] --> <string name="status_bar_settings_wifi_button">Wi-Fi</string> <!-- Name of the button that links to the Bluetooth settings screen. [CHAR LIMIT=NONE] --> <string name="status_bar_settings_bluetooth_button">Bluetooth</string> <!-- Label in the system panel for airplane mode (all radios are turned off)[CHAR LIMIT=30] --> <string name="status_bar_settings_airplane">Airplane mode</string> <!-- Label in the system panel for gps state [CHAR LIMIT=30] --> <string name="status_bar_settings_location">GPS</string> <!-- Label in the system panel for flashlight state [CHAR LIMIT=30] --> <string name="status_bar_settings_flashlight">LED flashlight</string> <!-- Label in the system panel for mobile data state [CHAR LIMIT=30] --> <string name="status_bar_settings_mobile_data">Mobile data</string> <!-- Label in the system panel for network mode [CHAR LIMIT=30] --> <string name="status_bar_settings_network_mode">2G/3G</string> <!-- Label in the system panel for sound [CHAR LIMIT=30] --> <string name="status_bar_settings_sound_mode">Sound</string> <!-- Label in system panel saying the device will use the orientation sensor to rotate [CHAR LIMIT=30] --> <string name="status_bar_settings_auto_rotation">Auto-rotate screen</string> Loading packages/SystemUI/src/com/android/systemui/statusbar/policy/BluetoothController.java +57 −5 Original line number Diff line number Diff line /* * Copyright (C) 2008 The Android Open Source Project * This code has been modified. Portions copyright (C) 2012 ParanoidAndroid Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. Loading @@ -25,31 +26,43 @@ import android.content.Intent; import android.content.IntentFilter; import android.view.View; import android.widget.ImageView; import android.widget.CompoundButton; import com.android.systemui.R; public class BluetoothController extends BroadcastReceiver { public class BluetoothController extends BroadcastReceiver implements CompoundButton.OnCheckedChangeListener { private static final String TAG = "StatusBar.BluetoothController"; private Context mContext; private ArrayList<ImageView> mIconViews = new ArrayList<ImageView>(); private CompoundButton mCheckBox; private final BluetoothAdapter mAdapter; private int mIconId = R.drawable.stat_sys_data_bluetooth; private int mContentDescriptionId = 0; private int mState = BluetoothAdapter.ERROR; private boolean mEnabled = false; public BluetoothController(Context context, CompoundButton checkbox) { this(context); mCheckBox = checkbox; mCheckBox.setChecked(mEnabled); mCheckBox.setOnCheckedChangeListener(this); } public BluetoothController(Context context) { mContext = context; mAdapter = BluetoothAdapter.getDefaultAdapter(); IntentFilter filter = new IntentFilter(); filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED); filter.addAction(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED); context.registerReceiver(this, filter); final BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); if (adapter != null) { handleAdapterStateChange(adapter.getState()); handleConnectionStateChange(adapter.getConnectionState()); if (mAdapter != null) { handleAdapterStateChange(mAdapter.getState()); handleConnectionStateChange(mAdapter.getConnectionState()); } refreshViews(); } Loading Loading @@ -77,6 +90,45 @@ public class BluetoothController extends BroadcastReceiver { mEnabled = (adapterState == BluetoothAdapter.STATE_ON); } public void onCheckedChanged(CompoundButton view, boolean checked) { if (checked != mEnabled) { mEnabled = checked; setBluetoothEnabled(mEnabled); setBluetoothStateInt(mAdapter.getState()); syncBluetoothState(); } } public void setBluetoothEnabled(boolean enabled) { boolean success = enabled ? mAdapter.enable() : mAdapter.disable(); if (success) setBluetoothStateInt(enabled ? BluetoothAdapter.STATE_TURNING_ON : BluetoothAdapter.STATE_TURNING_OFF); else syncBluetoothState(); } boolean syncBluetoothState() { int currentState = mAdapter.getState(); if (currentState != mState) { setBluetoothStateInt(mState); return true; } return false; } synchronized void setBluetoothStateInt(int state) { mState = state; if (state == BluetoothAdapter.STATE_ON){ if (mCheckBox != null) mCheckBox.setChecked(true); } else if (mCheckBox != null) mCheckBox.setChecked(false); } public void handleConnectionStateChange(int connectionState) { final boolean connected = (connectionState == BluetoothAdapter.STATE_CONNECTED); if (connected) { Loading packages/SystemUI/src/com/android/systemui/statusbar/policy/FlashlightController.java 0 → 100644 +55 −0 Original line number Diff line number Diff line /* * Copyright (C) 2011 The CyanogenMod Project * This code has been modified. Portions copyright (C) 2012 ParanoidAndroid 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.statusbar.policy; import android.content.BroadcastReceiver; import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.provider.Settings; import android.widget.CompoundButton; import com.android.systemui.R; public class FlashlightController implements CompoundButton.OnCheckedChangeListener { private static final String TAG = "StatusBar.FlashlightController"; private Context mContext; private CompoundButton mCheckBox; private boolean mFlashLight; public FlashlightController(Context context, CompoundButton checkbox) { mContext = context; mFlashLight = getFlashLight(); mCheckBox = checkbox; checkbox.setChecked(mFlashLight); checkbox.setOnCheckedChangeListener(this); } public void onCheckedChanged(CompoundButton view, boolean checked) { Intent i = new Intent("net.cactii.flash2.TOGGLE_FLASHLIGHT"); i.putExtra("bright", !checked); mContext.sendBroadcast(i); } private boolean getFlashLight() { ContentResolver cr = mContext.getContentResolver(); return Settings.System.getInt(cr, Settings.System.TORCH_STATE, 0) == 1; } } Loading
core/java/android/provider/Settings.java +1 −0 Original line number Diff line number Diff line Loading @@ -2358,6 +2358,7 @@ public final class Settings { public static final String WIDGET_BUTTONS_TABLET = "expanded_widget_buttons_tablet"; /** * Navigation controls to Use * * @hide Loading
packages/SystemUI/res/layout/system_bar_settings_view.xml +108 −18 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- * Copyright (C) 2010 The Android Open Source Project * This code has been modified. Portions copyright (C) 2012 ParanoidAndroid Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. Loading @@ -15,6 +16,11 @@ * limitations under the License. --> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="match_parent" android:layout_width="match_parent"> <com.android.systemui.statusbar.tablet.SettingsView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:systemui="http://schemas.android.com/apk/res/com.android.systemui" Loading @@ -23,75 +29,158 @@ android:orientation="vertical" > <!-- Airplane mode --> <!-- Toggle 1 --> <LinearLayout android:id="@+id/airplane" android:id="@+id/toggle_1" style="@style/StatusBarPanelSettingsRow" > <ImageView android:id="@+id/airplane_icon" android:id="@+id/toggle_1_icon" style="@style/StatusBarPanelSettingsIcon" android:src="@drawable/ic_sysbar_airplane_on" /> <TextView android:id="@+id/airplane_label" android:id="@+id/toggle_1_label" style="@style/StatusBarPanelSettingsContents" android:text="@string/status_bar_settings_airplane" /> <Switch android:id="@+id/airplane_checkbox" android:id="@+id/toggle_1_checkbox" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_marginRight="5dp" /> </LinearLayout> <View style="@style/StatusBarPanelSettingsPanelSeparator" /> <!-- Network --> <View android:id="@+id/rotate_separator" style="@style/StatusBarPanelSettingsPanelSeparator" /> <!-- Toggle 2 --> <LinearLayout android:id="@+id/network" android:id="@+id/toggle_2" style="@style/StatusBarPanelSettingsRow" > <ImageView android:id="@+id/network_icon" android:id="@+id/toggle_2_icon" style="@style/StatusBarPanelSettingsIcon" android:src="@drawable/ic_sysbar_wifi_on" /> <TextView android:id="@+id/network_label" android:id="@+id/toggle_2_label" style="@style/StatusBarPanelSettingsContents" android:text="@string/status_bar_settings_wifi_button" /> <Switch android:id="@+id/toggle_2_checkbox" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_marginRight="5dp" /> </LinearLayout> <View style="@style/StatusBarPanelSettingsPanelSeparator" /> <!-- Toggle 3 --> <LinearLayout android:id="@+id/toggle_3" style="@style/StatusBarPanelSettingsRow" > <ImageView android:id="@+id/toggle_3_icon" style="@style/StatusBarPanelSettingsIcon" android:src="@drawable/stat_sys_data_bluetooth" /> <TextView android:id="@+id/toggle_3_label" style="@style/StatusBarPanelSettingsContents" android:text="@string/status_bar_settings_bluetooth_button" /> <Switch android:id="@+id/toggle_3_checkbox" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_marginRight="5dp" /> </LinearLayout> <View style="@style/StatusBarPanelSettingsPanelSeparator" /> <!-- Rotation lock --> <!-- Toggle 4 --> <LinearLayout android:id="@+id/rotate" android:id="@+id/toggle_4" style="@style/StatusBarPanelSettingsRow" > <ImageView android:id="@+id/rotate_icon" android:id="@+id/toggle_4_icon" style="@style/StatusBarPanelSettingsIcon" android:src="@drawable/ic_sysbar_rotate_on" /> <TextView android:id="@+id/rotate_label" android:id="@+id/toggle_4_label" style="@style/StatusBarPanelSettingsContents" android:text="@string/status_bar_settings_auto_rotation" /> <Switch android:id="@+id/rotate_checkbox" android:id="@+id/toggle_4_checkbox" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_marginRight="5dp" /> </LinearLayout> <View android:id="@+id/rotate_separator" style="@style/StatusBarPanelSettingsPanelSeparator" /> <View style="@style/StatusBarPanelSettingsPanelSeparator" /> <!-- Toggle 5 --> <LinearLayout android:id="@+id/toggle_5" style="@style/StatusBarPanelSettingsRow" > <ImageView android:id="@+id/toggle_5_icon" style="@style/StatusBarPanelSettingsIcon" android:src="@drawable/stat_gps_on" /> <TextView android:id="@+id/toggle_5_label" style="@style/StatusBarPanelSettingsContents" android:text="@string/status_bar_settings_location" /> <Switch android:id="@+id/toggle_5_checkbox" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_marginRight="5dp" /> </LinearLayout> <View style="@style/StatusBarPanelSettingsPanelSeparator" /> <!-- Toggle 6 --> <LinearLayout android:id="@+id/toggle_6" style="@style/StatusBarPanelSettingsRow" > <ImageView android:id="@+id/toggle_6_icon" style="@style/StatusBarPanelSettingsIcon" android:src="@drawable/stat_flashlight_on" /> <TextView android:id="@+id/toggle_6_label" style="@style/StatusBarPanelSettingsContents" android:text="@string/status_bar_settings_flashlight" /> <Switch android:id="@+id/toggle_6_checkbox" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_marginRight="5dp" /> </LinearLayout> <View style="@style/StatusBarPanelSettingsPanelSeparator" /> <!-- Brightness --> <LinearLayout style="@style/StatusBarPanelSettingsRow" > Loading Loading @@ -155,3 +244,4 @@ </com.android.systemui.statusbar.tablet.SettingsView> </ScrollView>
packages/SystemUI/res/values/strings.xml +18 −0 Original line number Diff line number Diff line Loading @@ -96,9 +96,27 @@ <!-- Name of the button that links to the Wifi settings screen. [CHAR LIMIT=NONE] --> <string name="status_bar_settings_wifi_button">Wi-Fi</string> <!-- Name of the button that links to the Bluetooth settings screen. [CHAR LIMIT=NONE] --> <string name="status_bar_settings_bluetooth_button">Bluetooth</string> <!-- Label in the system panel for airplane mode (all radios are turned off)[CHAR LIMIT=30] --> <string name="status_bar_settings_airplane">Airplane mode</string> <!-- Label in the system panel for gps state [CHAR LIMIT=30] --> <string name="status_bar_settings_location">GPS</string> <!-- Label in the system panel for flashlight state [CHAR LIMIT=30] --> <string name="status_bar_settings_flashlight">LED flashlight</string> <!-- Label in the system panel for mobile data state [CHAR LIMIT=30] --> <string name="status_bar_settings_mobile_data">Mobile data</string> <!-- Label in the system panel for network mode [CHAR LIMIT=30] --> <string name="status_bar_settings_network_mode">2G/3G</string> <!-- Label in the system panel for sound [CHAR LIMIT=30] --> <string name="status_bar_settings_sound_mode">Sound</string> <!-- Label in system panel saying the device will use the orientation sensor to rotate [CHAR LIMIT=30] --> <string name="status_bar_settings_auto_rotation">Auto-rotate screen</string> Loading
packages/SystemUI/src/com/android/systemui/statusbar/policy/BluetoothController.java +57 −5 Original line number Diff line number Diff line /* * Copyright (C) 2008 The Android Open Source Project * This code has been modified. Portions copyright (C) 2012 ParanoidAndroid Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. Loading @@ -25,31 +26,43 @@ import android.content.Intent; import android.content.IntentFilter; import android.view.View; import android.widget.ImageView; import android.widget.CompoundButton; import com.android.systemui.R; public class BluetoothController extends BroadcastReceiver { public class BluetoothController extends BroadcastReceiver implements CompoundButton.OnCheckedChangeListener { private static final String TAG = "StatusBar.BluetoothController"; private Context mContext; private ArrayList<ImageView> mIconViews = new ArrayList<ImageView>(); private CompoundButton mCheckBox; private final BluetoothAdapter mAdapter; private int mIconId = R.drawable.stat_sys_data_bluetooth; private int mContentDescriptionId = 0; private int mState = BluetoothAdapter.ERROR; private boolean mEnabled = false; public BluetoothController(Context context, CompoundButton checkbox) { this(context); mCheckBox = checkbox; mCheckBox.setChecked(mEnabled); mCheckBox.setOnCheckedChangeListener(this); } public BluetoothController(Context context) { mContext = context; mAdapter = BluetoothAdapter.getDefaultAdapter(); IntentFilter filter = new IntentFilter(); filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED); filter.addAction(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED); context.registerReceiver(this, filter); final BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); if (adapter != null) { handleAdapterStateChange(adapter.getState()); handleConnectionStateChange(adapter.getConnectionState()); if (mAdapter != null) { handleAdapterStateChange(mAdapter.getState()); handleConnectionStateChange(mAdapter.getConnectionState()); } refreshViews(); } Loading Loading @@ -77,6 +90,45 @@ public class BluetoothController extends BroadcastReceiver { mEnabled = (adapterState == BluetoothAdapter.STATE_ON); } public void onCheckedChanged(CompoundButton view, boolean checked) { if (checked != mEnabled) { mEnabled = checked; setBluetoothEnabled(mEnabled); setBluetoothStateInt(mAdapter.getState()); syncBluetoothState(); } } public void setBluetoothEnabled(boolean enabled) { boolean success = enabled ? mAdapter.enable() : mAdapter.disable(); if (success) setBluetoothStateInt(enabled ? BluetoothAdapter.STATE_TURNING_ON : BluetoothAdapter.STATE_TURNING_OFF); else syncBluetoothState(); } boolean syncBluetoothState() { int currentState = mAdapter.getState(); if (currentState != mState) { setBluetoothStateInt(mState); return true; } return false; } synchronized void setBluetoothStateInt(int state) { mState = state; if (state == BluetoothAdapter.STATE_ON){ if (mCheckBox != null) mCheckBox.setChecked(true); } else if (mCheckBox != null) mCheckBox.setChecked(false); } public void handleConnectionStateChange(int connectionState) { final boolean connected = (connectionState == BluetoothAdapter.STATE_CONNECTED); if (connected) { Loading
packages/SystemUI/src/com/android/systemui/statusbar/policy/FlashlightController.java 0 → 100644 +55 −0 Original line number Diff line number Diff line /* * Copyright (C) 2011 The CyanogenMod Project * This code has been modified. Portions copyright (C) 2012 ParanoidAndroid 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.statusbar.policy; import android.content.BroadcastReceiver; import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.provider.Settings; import android.widget.CompoundButton; import com.android.systemui.R; public class FlashlightController implements CompoundButton.OnCheckedChangeListener { private static final String TAG = "StatusBar.FlashlightController"; private Context mContext; private CompoundButton mCheckBox; private boolean mFlashLight; public FlashlightController(Context context, CompoundButton checkbox) { mContext = context; mFlashLight = getFlashLight(); mCheckBox = checkbox; checkbox.setChecked(mFlashLight); checkbox.setOnCheckedChangeListener(this); } public void onCheckedChanged(CompoundButton view, boolean checked) { Intent i = new Intent("net.cactii.flash2.TOGGLE_FLASHLIGHT"); i.putExtra("bright", !checked); mContext.sendBroadcast(i); } private boolean getFlashLight() { ContentResolver cr = mContext.getContentResolver(); return Settings.System.getInt(cr, Settings.System.TORCH_STATE, 0) == 1; } }