diff options
author | Robert Burns <burnsra@gmail.com> | 2012-02-14 14:17:42 -0500 |
---|---|---|
committer | Steve Kondik <shade@chemlab.org> | 2012-02-28 23:57:38 -0800 |
commit | 5469cfa617b45136ca2003419b439e89539cda64 (patch) | |
tree | 8815d8e784ef03f7361076bb505d8cc423665275 /packages | |
parent | 24df693dcab37bcad67937a2822383f3afb5912a (diff) | |
download | frameworks_base-5469cfa617b45136ca2003419b439e89539cda64.zip frameworks_base-5469cfa617b45136ca2003419b439e89539cda64.tar.gz frameworks_base-5469cfa617b45136ca2003419b439e89539cda64.tar.bz2 |
Interface Settings: signal status style (2/2)
Ported from CM7 change I4984b06c70acd49862b5afc502cb4875abba64b7
Change-Id: Iebce598e278e8429444db862dd71547f57ea86ba
Diffstat (limited to 'packages')
-rw-r--r-- | packages/SystemUI/res/drawable-hdpi/stat_sys_signal_min.png | bin | 0 -> 3194 bytes | |||
-rwxr-xr-x | packages/SystemUI/res/drawable-mdpi/stat_sys_signal_min.png | bin | 0 -> 3052 bytes | |||
-rwxr-xr-x | packages/SystemUI/res/drawable-sw600dp-hdpi/stat_sys_signal_min.png | bin | 0 -> 3395 bytes | |||
-rwxr-xr-x | packages/SystemUI/res/drawable-sw600dp-mdpi/stat_sys_signal_min.png | bin | 0 -> 3151 bytes | |||
-rwxr-xr-x | packages/SystemUI/res/drawable-sw600dp-xhdpi/stat_sys_signal_min.png | bin | 0 -> 3588 bytes | |||
-rwxr-xr-x | packages/SystemUI/res/drawable-xhdpi/stat_sys_signal_min.png | bin | 0 -> 3425 bytes | |||
-rw-r--r-- | packages/SystemUI/res/layout-sw600dp/status_bar_notification_area.xml | 5 | ||||
-rw-r--r-- | packages/SystemUI/res/layout/signal_cluster_text_view.xml | 53 | ||||
-rw-r--r-- | packages/SystemUI/res/layout/status_bar.xml | 7 | ||||
-rw-r--r-- | packages/SystemUI/res/values/styles.xml | 7 | ||||
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterTextView.java | 177 | ||||
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java | 49 |
12 files changed, 294 insertions, 4 deletions
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_min.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_min.png Binary files differnew file mode 100644 index 0000000..c3f79ce --- /dev/null +++ b/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_min.png diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_min.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_min.png Binary files differnew file mode 100755 index 0000000..51a4c4c --- /dev/null +++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_min.png diff --git a/packages/SystemUI/res/drawable-sw600dp-hdpi/stat_sys_signal_min.png b/packages/SystemUI/res/drawable-sw600dp-hdpi/stat_sys_signal_min.png Binary files differnew file mode 100755 index 0000000..5f17531 --- /dev/null +++ b/packages/SystemUI/res/drawable-sw600dp-hdpi/stat_sys_signal_min.png diff --git a/packages/SystemUI/res/drawable-sw600dp-mdpi/stat_sys_signal_min.png b/packages/SystemUI/res/drawable-sw600dp-mdpi/stat_sys_signal_min.png Binary files differnew file mode 100755 index 0000000..fd0f879 --- /dev/null +++ b/packages/SystemUI/res/drawable-sw600dp-mdpi/stat_sys_signal_min.png diff --git a/packages/SystemUI/res/drawable-sw600dp-xhdpi/stat_sys_signal_min.png b/packages/SystemUI/res/drawable-sw600dp-xhdpi/stat_sys_signal_min.png Binary files differnew file mode 100755 index 0000000..cd7d4db --- /dev/null +++ b/packages/SystemUI/res/drawable-sw600dp-xhdpi/stat_sys_signal_min.png diff --git a/packages/SystemUI/res/drawable-xhdpi/stat_sys_signal_min.png b/packages/SystemUI/res/drawable-xhdpi/stat_sys_signal_min.png Binary files differnew file mode 100755 index 0000000..1203d7e --- /dev/null +++ b/packages/SystemUI/res/drawable-xhdpi/stat_sys_signal_min.png diff --git a/packages/SystemUI/res/layout-sw600dp/status_bar_notification_area.xml b/packages/SystemUI/res/layout-sw600dp/status_bar_notification_area.xml index a19be0b..3fbe348 100644 --- a/packages/SystemUI/res/layout-sw600dp/status_bar_notification_area.xml +++ b/packages/SystemUI/res/layout-sw600dp/status_bar_notification_area.xml @@ -121,6 +121,11 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <include layout="@layout/signal_cluster_text_view" + android:id="@+id/signal_cluster_text" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + /> <ImageView android:id="@+id/bluetooth" android:layout_height="wrap_content" diff --git a/packages/SystemUI/res/layout/signal_cluster_text_view.xml b/packages/SystemUI/res/layout/signal_cluster_text_view.xml new file mode 100644 index 0000000..9428ca2 --- /dev/null +++ b/packages/SystemUI/res/layout/signal_cluster_text_view.xml @@ -0,0 +1,53 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* apps/common/assets/default/default/skins/StatusBar.xml +** +** Copyright 2011, 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. +*/ +--> + +<com.android.systemui.statusbar.SignalClusterTextView + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_height="wrap_content" + android:layout_width="wrap_content" + android:orientation="horizontal" + > + <LinearLayout + android:id="@+id/mobile_signal_text_combo" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:orientation="horizontal" + android:gravity="center" + android:layout_marginRight="-3dip" + > + <TextView + android:id="@+id/mobile_signal_text" + android:textAppearance="@style/TextAppearance.StatusBar.Signal" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:singleLine="true" + android:layout_marginRight="-3dip" + android:gravity="center_vertical|left" + /> + <ImageView + android:id="@+id/mobile_signal_text_icon" + android:src="@drawable/stat_sys_signal_min" + android:layout_height="wrap_content" + android:layout_width="wrap_content" + android:layout_marginLeft="1dip" + android:paddingRight="2dip" + /> + </LinearLayout> +</com.android.systemui.statusbar.SignalClusterTextView> diff --git a/packages/SystemUI/res/layout/status_bar.xml b/packages/SystemUI/res/layout/status_bar.xml index 5af56ef..cfc48ee 100644 --- a/packages/SystemUI/res/layout/status_bar.xml +++ b/packages/SystemUI/res/layout/status_bar.xml @@ -71,11 +71,16 @@ android:orientation="horizontal" android:gravity="center" > - <include layout="@layout/signal_cluster_view" + <include layout="@layout/signal_cluster_view" android:id="@+id/signal_cluster" android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <include layout="@layout/signal_cluster_text_view" + android:id="@+id/signal_cluster_text" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + /> <TextView android:id="@+id/battery_text" android:textAppearance="@style/TextAppearance.StatusBar.Battery" diff --git a/packages/SystemUI/res/values/styles.xml b/packages/SystemUI/res/values/styles.xml index ebe8e70..51bd0cf 100644 --- a/packages/SystemUI/res/values/styles.xml +++ b/packages/SystemUI/res/values/styles.xml @@ -60,6 +60,13 @@ <item name="android:textColor">@android:color/holo_blue_light</item> </style> + <style name="TextAppearance.StatusBar.Signal" parent="@*android:style/TextAppearance.StatusBar.Icon"> + <!-- Note: must be dp to fit in status bar --> + <item name="android:textSize">12dp</item> + <item name="android:textStyle">normal</item> + <item name="android:textColor">@android:color/holo_blue_light</item> + </style> + <style name="Animation" /> <style name="Animation.ShirtPocketPanel"> diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterTextView.java b/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterTextView.java new file mode 100644 index 0000000..65ac030 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterTextView.java @@ -0,0 +1,177 @@ +/* + * Copyright (C) 2011 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.content.BroadcastReceiver; +import android.content.ContentResolver; +import android.content.Context; +import android.content.Intent; +import android.database.ContentObserver; +import android.os.Handler; +import android.provider.Settings; +import android.telephony.PhoneStateListener; +import android.telephony.ServiceState; +import android.telephony.SignalStrength; +import android.telephony.TelephonyManager; +import android.text.Spannable; +import android.text.SpannableStringBuilder; +import android.text.style.CharacterStyle; +import android.text.style.RelativeSizeSpan; +import android.util.AttributeSet; +import android.util.Slog; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.TextView; + +import com.android.systemui.statusbar.SignalClusterView.SettingsObserver; +import com.android.systemui.statusbar.policy.NetworkController; +import com.android.systemui.R; + +// Intimately tied to the design of res/layout/signal_cluster_text_view.xml +public class SignalClusterTextView + extends LinearLayout { + + private static final int SIGNAL_CLUSTER_STYLE_NORMAL = 0; + private static final int SIGNAL_CLUSTER_STYLE_TEXT = 1; + private static final int SIGNAL_CLUSTER_STYLE_HIDDEN = 2; + + private boolean mAttached; + private boolean mAirplaneMode; + private int mSignalClusterStyle; + private int mPhoneState; + + private SignalStrength signalStrength; + + ViewGroup mMobileGroup; + TextView mMobileSignalText; + + Handler mHandler; + + int dBm = 0; + + class SettingsObserver extends ContentObserver { + SettingsObserver(Handler handler) { + super(handler); + } + + void observe() { + ContentResolver resolver = mContext.getContentResolver(); + resolver.registerContentObserver(Settings.System.getUriFor( + Settings.System.STATUS_BAR_SIGNAL_TEXT), false, this); + } + + @Override public void onChange(boolean selfChange) { + updateSettings(); + } + } + + public SignalClusterTextView(Context context) { + this(context, null); + } + + public SignalClusterTextView(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + public SignalClusterTextView(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + + mHandler = new Handler(); + + SettingsObserver settingsObserver = new SettingsObserver(mHandler); + settingsObserver.observe(); + } + + @Override + protected void onAttachedToWindow() { + super.onAttachedToWindow(); + + mMobileGroup = (ViewGroup) findViewById(R.id.mobile_signal_text_combo); + mMobileSignalText = (TextView) findViewById(R.id.mobile_signal_text); + + if (!mAttached) { + mAttached = true; + ((TelephonyManager) getContext().getSystemService(Context.TELEPHONY_SERVICE)).listen( + mPhoneStateListener, PhoneStateListener.LISTEN_SERVICE_STATE + | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS); + + updateSettings(); + } + } + + @Override + protected void onDetachedFromWindow() { + if (mAttached) { + mAttached = false; + } + super.onDetachedFromWindow(); + } + + private String getSignalLevelString(int dBm) { + if (dBm == 0) { + return "-\u221e"; // -oo ('minus infinity') + } + return Integer.toString(dBm); + } + + final void updateSignalText() { + + if (mAirplaneMode || dBm == 0) { + mMobileGroup.setVisibility(View.GONE); + return; + } else if (mSignalClusterStyle == SIGNAL_CLUSTER_STYLE_TEXT) { + mMobileGroup.setVisibility(View.VISIBLE); + mMobileSignalText.setText(getSignalLevelString(dBm)); + } else { + mMobileGroup.setVisibility(View.GONE); + } + } + + /* + * Phone listener to update signal information + */ + private PhoneStateListener mPhoneStateListener = new PhoneStateListener() { + @Override + public void onSignalStrengthsChanged(SignalStrength signalStrength) { + if (signalStrength != null) { + dBm = signalStrength.getDbm(); + } else { + dBm = 0; + } + + // update text if it's visible + if (mAttached) { + updateSettings(); + } + } + + public void onServiceStateChanged(ServiceState serviceState) { + mAirplaneMode = serviceState.getState() == ServiceState.STATE_POWER_OFF; + updateSettings(); + } + }; + + private void updateSettings() { + ContentResolver resolver = mContext.getContentResolver(); + mSignalClusterStyle = (Settings.System.getInt(resolver, + Settings.System.STATUS_BAR_SIGNAL_TEXT, SIGNAL_CLUSTER_STYLE_NORMAL)); + updateSignalText(); + } +} + diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java b/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java index 744a46b..b9ecc8b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java @@ -16,17 +16,19 @@ package com.android.systemui.statusbar; +import android.content.ContentResolver; import android.content.Context; +import android.database.ContentObserver; +import android.os.Handler; +import android.provider.Settings; import android.util.AttributeSet; import android.util.Slog; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.LinearLayout; -import android.widget.TextView; import com.android.systemui.statusbar.policy.NetworkController; - import com.android.systemui.R; // Intimately tied to the design of res/layout/signal_cluster_view.xml @@ -34,9 +36,11 @@ public class SignalClusterView extends LinearLayout implements NetworkController.SignalCluster { + private static final int SIGNAL_CLUSTER_STYLE_NORMAL = 0; + static final boolean DEBUG = false; static final String TAG = "SignalClusterView"; - + NetworkController mNC; private boolean mWifiVisible = false; @@ -46,10 +50,31 @@ public class SignalClusterView private boolean mIsAirplaneMode = false; private String mWifiDescription, mMobileDescription, mMobileTypeDescription; + private int mSignalClusterStyle; + ViewGroup mWifiGroup, mMobileGroup; ImageView mWifi, mMobile, mWifiActivity, mMobileActivity, mMobileType; View mSpacer; + Handler mHandler; + + class SettingsObserver extends ContentObserver { + SettingsObserver(Handler handler) { + super(handler); + } + + void observe() { + ContentResolver resolver = mContext.getContentResolver(); + resolver.registerContentObserver(Settings.System.getUriFor( + Settings.System.STATUS_BAR_SIGNAL_TEXT), false, this); + } + + @Override + public void onChange(boolean selfChange) { + updateSettings(); + } + } + public SignalClusterView(Context context) { this(context, null); } @@ -60,6 +85,11 @@ public class SignalClusterView public SignalClusterView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); + + mHandler = new Handler(); + + SettingsObserver settingsObserver = new SettingsObserver(mHandler); + settingsObserver.observe(); } public void setNetworkController(NetworkController nc) { @@ -163,6 +193,19 @@ public class SignalClusterView mMobileType.setVisibility( !mWifiVisible ? View.VISIBLE : View.GONE); + + updateSettings(); + } + + private void updateSignalClusterStyle() { + mMobileGroup.setVisibility(mSignalClusterStyle != SIGNAL_CLUSTER_STYLE_NORMAL ? View.GONE : View.VISIBLE); + } + + private void updateSettings() { + ContentResolver resolver = mContext.getContentResolver(); + mSignalClusterStyle = (Settings.System.getInt(resolver, + Settings.System.STATUS_BAR_SIGNAL_TEXT, SIGNAL_CLUSTER_STYLE_NORMAL)); + updateSignalClusterStyle(); } } |