diff options
Diffstat (limited to 'packages')
8 files changed, 216 insertions, 9 deletions
diff --git a/packages/SystemUI/res/layout-xlarge/status_bar.xml b/packages/SystemUI/res/layout-xlarge/status_bar.xml index d4e9c53..758377b 100644 --- a/packages/SystemUI/res/layout-xlarge/status_bar.xml +++ b/packages/SystemUI/res/layout-xlarge/status_bar.xml @@ -82,14 +82,24 @@ android:orientation="horizontal" android:gravity="center" > - <ImageView - android:id="@+id/network" + <FrameLayout android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_gravity="top" android:layout_marginTop="19dp" android:layout_marginRight="4dp" - /> + > + <ImageView + android:id="@+id/network_signal" + android:layout_height="wrap_content" + android:layout_width="wrap_content" + /> + <ImageView + android:id="@+id/network_type" + android:layout_height="wrap_content" + android:layout_width="wrap_content" + /> + </FrameLayout> <ImageView android:id="@+id/battery" android:layout_height="wrap_content" diff --git a/packages/SystemUI/res/layout-xlarge/status_bar_notification_panel.xml b/packages/SystemUI/res/layout-xlarge/status_bar_notification_panel.xml index c0612c8..1d98458 100644 --- a/packages/SystemUI/res/layout-xlarge/status_bar_notification_panel.xml +++ b/packages/SystemUI/res/layout-xlarge/status_bar_notification_panel.xml @@ -95,7 +95,17 @@ /> <ImageView - android:id="@+id/network" + android:id="@+id/network_signal" + android:layout_height="wrap_content" + android:layout_width="wrap_content" + android:layout_toRightOf="@id/battery_text" + android:layout_alignBaseline="@id/battery" + android:layout_marginRight="8dp" + android:baseline="15dp" + /> + + <ImageView + android:id="@+id/network_type" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_toRightOf="@id/battery_text" @@ -109,7 +119,7 @@ style="@style/StatusBarNotificationText" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_toRightOf="@id/network" + android:layout_toRightOf="@id/network_signal" android:layout_alignBaseline="@id/battery" android:singleLine="true" android:text="@string/status_bar_settings_settings_button" diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/DoNotDisturb.java b/packages/SystemUI/src/com/android/systemui/statusbar/DoNotDisturb.java new file mode 100644 index 0000000..9e44e71 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/statusbar/DoNotDisturb.java @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2010 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.statusbar; + +import android.app.StatusBarManager; +import android.content.ContentResolver; +import android.content.Context; +import android.content.SharedPreferences; +import android.os.RemoteException; +import android.os.ServiceManager; +import android.util.Slog; + +import com.android.systemui.statusbar.policy.Prefs; + +public class DoNotDisturb implements SharedPreferences.OnSharedPreferenceChangeListener { + private Context mContext; + private StatusBarManager mStatusBar; + SharedPreferences mPrefs; + private boolean mDoNotDisturb; + + public DoNotDisturb(Context context) { + mContext = context; + mStatusBar = (StatusBarManager)context.getSystemService(Context.STATUS_BAR_SERVICE); + mPrefs = Prefs.read(context); + mPrefs.registerOnSharedPreferenceChangeListener(this); + mDoNotDisturb = mPrefs.getBoolean(Prefs.DO_NOT_DISTURB_PREF, Prefs.DO_NOT_DISTURB_DEFAULT); + updateDisableRecord(); + } + + public void onSharedPreferenceChanged(SharedPreferences prefs, String key) { + final boolean val = prefs.getBoolean(Prefs.DO_NOT_DISTURB_PREF, + Prefs.DO_NOT_DISTURB_DEFAULT); + if (val != mDoNotDisturb) { + mDoNotDisturb = val; + updateDisableRecord(); + } + } + + private void updateDisableRecord() { + final int disabled = StatusBarManager.DISABLE_NOTIFICATION_ICONS + | StatusBarManager.DISABLE_NOTIFICATION_ALERTS + | StatusBarManager.DISABLE_NOTIFICATION_TICKER; + mStatusBar.disable(mDoNotDisturb ? disabled : 0); + } +} + diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBar.java index d7f3730..472a225 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBar.java @@ -53,6 +53,8 @@ public abstract class StatusBar extends SystemUI implements CommandQueue.Callbac protected abstract View makeStatusBarView(); protected abstract int getStatusBarGravity(); + private DoNotDisturb mDoNotDisturb; + public void start() { // First set up our views and stuff. View sb = makeStatusBarView(); @@ -127,5 +129,7 @@ public abstract class StatusBar extends SystemUI implements CommandQueue.Callbac + " imeButton=" + switches[3] ); } + + mDoNotDisturb = new DoNotDisturb(mContext); } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/DoNotDisturbController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/DoNotDisturbController.java new file mode 100644 index 0000000..94c8aa5 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/DoNotDisturbController.java @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2010 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.statusbar.policy; + +import android.content.ContentResolver; +import android.content.Context; +import android.content.SharedPreferences; +import android.os.RemoteException; +import android.os.ServiceManager; +import android.provider.Settings; +import android.util.Slog; +import android.view.IWindowManager; +import android.widget.CompoundButton; + +public class DoNotDisturbController implements CompoundButton.OnCheckedChangeListener, + SharedPreferences.OnSharedPreferenceChangeListener { + private static final String TAG = "StatusBar.DoNotDisturbController"; + + SharedPreferences mPrefs; + private Context mContext; + private CompoundButton mCheckBox; + + private boolean mDoNotDisturb; + + public DoNotDisturbController(Context context, CompoundButton checkbox) { + mContext = context; + + mPrefs = Prefs.read(context); + mPrefs.registerOnSharedPreferenceChangeListener(this); + mDoNotDisturb = mPrefs.getBoolean(Prefs.DO_NOT_DISTURB_PREF, Prefs.DO_NOT_DISTURB_DEFAULT); + + mCheckBox = checkbox; + checkbox.setOnCheckedChangeListener(this); + + checkbox.setChecked(!mDoNotDisturb); + } + + // The checkbox is ON for notifications coming in and OFF for Do not disturb, so we + // don't have a double negative. + public void onCheckedChanged(CompoundButton view, boolean checked) { + //Slog.d(TAG, "onCheckedChanged checked=" + checked + " mDoNotDisturb=" + mDoNotDisturb); + final boolean value = !checked; + if (value != mDoNotDisturb) { + SharedPreferences.Editor editor = Prefs.edit(mContext); + editor.putBoolean(Prefs.DO_NOT_DISTURB_PREF, value); + editor.apply(); + } + } + + public void onSharedPreferenceChanged(SharedPreferences prefs, String key) { + final boolean val = prefs.getBoolean(Prefs.DO_NOT_DISTURB_PREF, + Prefs.DO_NOT_DISTURB_DEFAULT); + if (val != mDoNotDisturb) { + mDoNotDisturb = val; + mCheckBox.setChecked(!val); + } + } + + public void release() { + mPrefs.unregisterOnSharedPreferenceChangeListener(this); + } +} + diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/Prefs.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/Prefs.java new file mode 100644 index 0000000..05eafe8 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/Prefs.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2010 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.statusbar.policy; + +import android.content.Context; +import android.content.SharedPreferences; + +public class Prefs { + private static final String SHARED_PREFS_NAME = "status_bar"; + + // a boolean + public static final String DO_NOT_DISTURB_PREF = "do_not_disturb"; + public static final boolean DO_NOT_DISTURB_DEFAULT = false; + + public static SharedPreferences read(Context context) { + return context.getSharedPreferences(Prefs.SHARED_PREFS_NAME, Context.MODE_PRIVATE); + } + + public static SharedPreferences.Editor edit(Context context) { + return context.getSharedPreferences(Prefs.SHARED_PREFS_NAME, Context.MODE_PRIVATE).edit(); + } +} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/SettingsView.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/SettingsView.java index f9ba908..d1f8dd0 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/SettingsView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/SettingsView.java @@ -31,12 +31,14 @@ import android.widget.TextView; import com.android.systemui.R; import com.android.systemui.statusbar.policy.AirplaneModeController; import com.android.systemui.statusbar.policy.AutoRotateController; +import com.android.systemui.statusbar.policy.DoNotDisturbController; public class SettingsView extends LinearLayout implements View.OnClickListener { static final String TAG = "SettingsView"; AirplaneModeController mAirplane; AutoRotateController mRotate; + DoNotDisturbController mDoNotDisturb; public SettingsView(Context context, AttributeSet attrs) { this(context, attrs, 0); @@ -57,6 +59,8 @@ public class SettingsView extends LinearLayout implements View.OnClickListener { findViewById(R.id.network).setOnClickListener(this); mRotate = new AutoRotateController(context, (CompoundButton)findViewById(R.id.rotate_checkbox)); + mDoNotDisturb = new DoNotDisturbController(context, + (CompoundButton)findViewById(R.id.do_not_disturb_checkbox)); findViewById(R.id.settings).setOnClickListener(this); } @@ -64,6 +68,7 @@ public class SettingsView extends LinearLayout implements View.OnClickListener { protected void onDetachedFromWindow() { super.onDetachedFromWindow(); mAirplane.release(); + mDoNotDisturb.release(); } public void onClick(View v) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java index 3cae088..c55c87e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java @@ -159,7 +159,9 @@ public class TabletStatusBar extends StatusBar { mBatteryController.addLabelView( (TextView)mNotificationPanel.findViewById(R.id.battery_text)); mNetworkController.addCombinedSignalIconView( - (ImageView)mNotificationPanel.findViewById(R.id.network)); + (ImageView)mNotificationPanel.findViewById(R.id.network_signal)); + mNetworkController.addDataTypeIconView( + (ImageView)mNotificationPanel.findViewById(R.id.network_type)); mNetworkController.addLabelView( (TextView)mNotificationPanel.findViewById(R.id.network_text)); @@ -283,7 +285,10 @@ public class TabletStatusBar extends StatusBar { mBatteryController = new BatteryController(mContext); mBatteryController.addIconView((ImageView)sb.findViewById(R.id.battery)); mNetworkController = new NetworkController(mContext); - mNetworkController.addCombinedSignalIconView((ImageView)sb.findViewById(R.id.network)); + mNetworkController.addCombinedSignalIconView( + (ImageView)sb.findViewById(R.id.network_signal)); + mNetworkController.addDataTypeIconView( + (ImageView)sb.findViewById(R.id.network_type)); // The navigation buttons mNavigationArea = sb.findViewById(R.id.navigationArea); @@ -580,12 +585,12 @@ public class TabletStatusBar extends StatusBar { if ((state & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) { Slog.d(TAG, "DISABLE_NOTIFICATION_ICONS: yes"); // synchronize with current shadow state - mShadowController.hideElement(mNotificationArea); + mShadowController.hideElement(mNotificationIconArea); mTicker.halt(); } else { Slog.d(TAG, "DISABLE_NOTIFICATION_ICONS: no"); // synchronize with current shadow state - mShadowController.showElement(mNotificationArea); + mShadowController.showElement(mNotificationIconArea); } } else if ((diff & StatusBarManager.DISABLE_NOTIFICATION_TICKER) != 0) { if ((state & StatusBarManager.DISABLE_NOTIFICATION_TICKER) != 0) { |