Adding data type overlay to network tile.
Change-Id: Iae3c188e2f7f03bd1ebaddc756021be312ddb0aa
diff --git a/packages/SystemUI/res/layout/quick_settings_tile_rssi.xml b/packages/SystemUI/res/layout/quick_settings_tile_rssi.xml
index 3cbefa5..febd8a8 100644
--- a/packages/SystemUI/res/layout/quick_settings_tile_rssi.xml
+++ b/packages/SystemUI/res/layout/quick_settings_tile_rssi.xml
@@ -13,13 +13,38 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<TextView
+<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
- style="@style/TextAppearance.QuickSettings.TileView"
- android:id="@+id/rssi_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
- android:gravity="center"
- android:text="@string/quick_settings_rssi_label"
- />
\ No newline at end of file
+ android:orientation="vertical">
+ <FrameLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center">
+ <ImageView
+ android:id="@+id/rssi_image"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:paddingBottom="10dp"
+ />
+ <ImageView
+ android:id="@+id/rssi_overlay_image"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:paddingBottom="10dp"
+ />
+ </FrameLayout>
+ <TextView
+ style="@style/TextAppearance.QuickSettings.TileView"
+ android:id="@+id/rssi_textview"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:gravity="center"
+ android:text="@string/quick_settings_rssi_label"
+ />
+</LinearLayout>
\ No newline at end of file
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java
index 255ab16..3a10155 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java
@@ -29,6 +29,7 @@
import android.content.res.Resources;
import android.database.Cursor;
import android.graphics.drawable.Drawable;
+import android.graphics.drawable.LayerDrawable;
import android.graphics.drawable.LevelListDrawable;
import android.hardware.display.DisplayManager;
import android.hardware.display.WifiDisplay;
@@ -50,6 +51,7 @@
import com.android.internal.view.RotationPolicy;
import com.android.systemui.R;
+import com.android.systemui.statusbar.phone.QuickSettingsModel.RSSIState;
import com.android.systemui.statusbar.phone.QuickSettingsModel.State;
import com.android.systemui.statusbar.phone.QuickSettingsModel.UserState;
import com.android.systemui.statusbar.policy.BatteryController;
@@ -295,8 +297,16 @@
mModel.addRSSITile(rssiTile, new QuickSettingsModel.RefreshCallback() {
@Override
public void refreshView(QuickSettingsTileView view, State state) {
+ RSSIState rssiState = (RSSIState) state;
+ ImageView iv = (ImageView) view.findViewById(R.id.rssi_image);
+ ImageView iov = (ImageView) view.findViewById(R.id.rssi_overlay_image);
TextView tv = (TextView) view.findViewById(R.id.rssi_textview);
- tv.setCompoundDrawablesRelativeWithIntrinsicBounds(0, state.iconId, 0, 0);
+ iv.setImageResource(rssiState.signalIconId);
+ if (rssiState.dataTypeIconId > 0) {
+ iov.setImageResource(rssiState.dataTypeIconId);
+ } else {
+ iov.setImageDrawable(null);
+ }
tv.setText(state.label);
}
});
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsModel.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsModel.java
index cecb1ef..031504f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsModel.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsModel.java
@@ -60,6 +60,10 @@
int batteryLevel;
boolean pluggedIn;
}
+ static class RSSIState extends State {
+ int signalIconId;
+ int dataTypeIconId;
+ }
static class UserState extends State {
Drawable avatar;
}
@@ -124,7 +128,7 @@
private QuickSettingsTileView mRSSITile;
private RefreshCallback mRSSICallback;
- private State mRSSIState = new State();
+ private RSSIState mRSSIState = new RSSIState();
private QuickSettingsTileView mBluetoothTile;
private RefreshCallback mBluetoothCallback;
@@ -258,13 +262,16 @@
// NetworkSignalChanged callback
@Override
public void onMobileDataSignalChanged(boolean enabled, int mobileSignalIconId,
- String enabledDesc) {
+ int dataTypeIconId, String enabledDesc) {
if (deviceSupportsTelephony()) {
// TODO: If view is in awaiting state, disable
Resources r = mContext.getResources();
- mRSSIState.iconId = enabled && (mobileSignalIconId > 0)
+ mRSSIState.signalIconId = enabled && (mobileSignalIconId > 0)
? mobileSignalIconId
: R.drawable.ic_qs_signal_no_signal;
+ mRSSIState.dataTypeIconId = enabled && (dataTypeIconId > 0)
+ ? dataTypeIconId
+ : 0;
mRSSIState.label = enabled
? enabledDesc
: r.getString(R.string.quick_settings_rssi_emergency_only);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java
index 0bdc59b..556ae59 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java
@@ -16,11 +16,6 @@
package com.android.systemui.statusbar.policy;
-import java.io.FileDescriptor;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.List;
-
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -37,9 +32,7 @@
import android.os.Message;
import android.os.Messenger;
import android.os.RemoteException;
-import android.os.SystemProperties;
import android.provider.Settings;
-import android.provider.Telephony;
import android.telephony.PhoneStateListener;
import android.telephony.ServiceState;
import android.telephony.SignalStrength;
@@ -50,15 +43,18 @@
import android.widget.TextView;
import com.android.internal.app.IBatteryStats;
-import com.android.internal.telephony.IccCard;
import com.android.internal.telephony.IccCardConstants;
import com.android.internal.telephony.TelephonyIntents;
import com.android.internal.telephony.cdma.EriInfo;
-import com.android.server.am.BatteryStatsService;
import com.android.internal.util.AsyncChannel;
-
+import com.android.server.am.BatteryStatsService;
import com.android.systemui.R;
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.List;
+
public class NetworkController extends BroadcastReceiver {
// debug
static final String TAG = "StatusBar.NetworkController";
@@ -85,6 +81,7 @@
int mDataDirectionIconId; // data + data direction on phones
int mDataSignalIconId;
int mDataTypeIconId;
+ int mQSDataTypeIconId;
int mAirplaneIconId;
boolean mDataActive;
int mMobileActivityIconId; // overlay arrows for data direction
@@ -178,7 +175,8 @@
public interface NetworkSignalChangedCallback {
void onWifiSignalChanged(boolean enabled, int wifiSignalIconId, String description);
- void onMobileDataSignalChanged(boolean enabled, int mobileSignalIconId, String description);
+ void onMobileDataSignalChanged(boolean enabled, int mobileSignalIconId, int dataTypeIconId,
+ String description);
void onAirplaneModeChanged(boolean enabled);
}
@@ -352,15 +350,16 @@
cb.onWifiSignalChanged(wifiEnabled, mQSWifiIconId, wifiDesc);
if (isEmergencyOnly()) {
- cb.onMobileDataSignalChanged(false, mQSPhoneSignalIconId, null);
+ cb.onMobileDataSignalChanged(false, mQSPhoneSignalIconId, mQSDataTypeIconId, null);
} else {
if (mIsWimaxEnabled && mWimaxConnected) {
- // wimax is special
- cb.onMobileDataSignalChanged(true, mQSPhoneSignalIconId, mNetworkName);
- } else {
- // normal mobile data
- cb.onMobileDataSignalChanged(mHasMobileDataFeature, mQSPhoneSignalIconId,
+ // Wimax is special
+ cb.onMobileDataSignalChanged(true, mQSPhoneSignalIconId, mQSDataTypeIconId,
mNetworkName);
+ } else {
+ // Normal mobile data
+ cb.onMobileDataSignalChanged(mHasMobileDataFeature, mQSPhoneSignalIconId,
+ mQSDataTypeIconId, mNetworkName);
}
}
cb.onAirplaneModeChanged(mAirplaneMode);
@@ -570,6 +569,7 @@
// wimax is a special 4g network not handled by telephony
mDataIconList = TelephonyIcons.DATA_4G[mInetCondition];
mDataTypeIconId = R.drawable.stat_sys_data_connected_4g;
+ mQSDataTypeIconId = R.drawable.ic_qs_signal_4g;
mContentDescriptionDataType = mContext.getString(
R.string.accessibility_data_connection_4g);
} else {
@@ -578,6 +578,7 @@
if (!mShowAtLeastThreeGees) {
mDataIconList = TelephonyIcons.DATA_G[mInetCondition];
mDataTypeIconId = 0;
+ mQSDataTypeIconId = 0;
mContentDescriptionDataType = mContext.getString(
R.string.accessibility_data_connection_gprs);
break;
@@ -588,6 +589,7 @@
if (!mShowAtLeastThreeGees) {
mDataIconList = TelephonyIcons.DATA_E[mInetCondition];
mDataTypeIconId = R.drawable.stat_sys_data_connected_e;
+ mQSDataTypeIconId = R.drawable.ic_qs_signal_e;
mContentDescriptionDataType = mContext.getString(
R.string.accessibility_data_connection_edge);
break;
@@ -597,6 +599,7 @@
case TelephonyManager.NETWORK_TYPE_UMTS:
mDataIconList = TelephonyIcons.DATA_3G[mInetCondition];
mDataTypeIconId = R.drawable.stat_sys_data_connected_3g;
+ mQSDataTypeIconId = R.drawable.ic_qs_signal_3g;
mContentDescriptionDataType = mContext.getString(
R.string.accessibility_data_connection_3g);
break;
@@ -607,11 +610,13 @@
if (mHspaDataDistinguishable) {
mDataIconList = TelephonyIcons.DATA_H[mInetCondition];
mDataTypeIconId = R.drawable.stat_sys_data_connected_h;
+ mQSDataTypeIconId = R.drawable.ic_qs_signal_h;
mContentDescriptionDataType = mContext.getString(
R.string.accessibility_data_connection_3_5g);
} else {
mDataIconList = TelephonyIcons.DATA_3G[mInetCondition];
mDataTypeIconId = R.drawable.stat_sys_data_connected_3g;
+ mQSDataTypeIconId = R.drawable.ic_qs_signal_3g;
mContentDescriptionDataType = mContext.getString(
R.string.accessibility_data_connection_3g);
}
@@ -621,6 +626,7 @@
// display 1xRTT for IS95A/B
mDataIconList = TelephonyIcons.DATA_1X[mInetCondition];
mDataTypeIconId = R.drawable.stat_sys_data_connected_1x;
+ mQSDataTypeIconId = R.drawable.ic_qs_signal_1x;
mContentDescriptionDataType = mContext.getString(
R.string.accessibility_data_connection_cdma);
break;
@@ -631,6 +637,7 @@
if (!mShowAtLeastThreeGees) {
mDataIconList = TelephonyIcons.DATA_1X[mInetCondition];
mDataTypeIconId = R.drawable.stat_sys_data_connected_1x;
+ mQSDataTypeIconId = R.drawable.ic_qs_signal_1x;
mContentDescriptionDataType = mContext.getString(
R.string.accessibility_data_connection_cdma);
break;
@@ -643,12 +650,14 @@
case TelephonyManager.NETWORK_TYPE_EHRPD:
mDataIconList = TelephonyIcons.DATA_3G[mInetCondition];
mDataTypeIconId = R.drawable.stat_sys_data_connected_3g;
+ mQSDataTypeIconId = R.drawable.ic_qs_signal_3g;
mContentDescriptionDataType = mContext.getString(
R.string.accessibility_data_connection_3g);
break;
case TelephonyManager.NETWORK_TYPE_LTE:
mDataIconList = TelephonyIcons.DATA_4G[mInetCondition];
mDataTypeIconId = R.drawable.stat_sys_data_connected_4g;
+ mQSDataTypeIconId = R.drawable.ic_qs_signal_4g;
mContentDescriptionDataType = mContext.getString(
R.string.accessibility_data_connection_4g);
break;
@@ -656,11 +665,13 @@
if (!mShowAtLeastThreeGees) {
mDataIconList = TelephonyIcons.DATA_G[mInetCondition];
mDataTypeIconId = R.drawable.stat_sys_data_connected_g;
+ mQSDataTypeIconId = R.drawable.ic_qs_signal_g;
mContentDescriptionDataType = mContext.getString(
R.string.accessibility_data_connection_gprs);
} else {
mDataIconList = TelephonyIcons.DATA_3G[mInetCondition];
mDataTypeIconId = R.drawable.stat_sys_data_connected_3g;
+ mQSDataTypeIconId = R.drawable.ic_qs_signal_3g;
mContentDescriptionDataType = mContext.getString(
R.string.accessibility_data_connection_3g);
}
@@ -671,9 +682,11 @@
if (isCdma()) {
if (isCdmaEri()) {
mDataTypeIconId = R.drawable.stat_sys_data_connected_roam;
+ mQSDataTypeIconId = R.drawable.ic_qs_signal_r;
}
} else if (mPhone.isNetworkRoaming()) {
mDataTypeIconId = R.drawable.stat_sys_data_connected_roam;
+ mQSDataTypeIconId = R.drawable.ic_qs_signal_r;
}
}
@@ -1095,7 +1108,7 @@
mContentDescriptionPhoneSignal = mContext.getString(
R.string.accessibility_airplane_mode);
mAirplaneIconId = R.drawable.stat_sys_signal_flightmode;
- mPhoneSignalIconId = mDataSignalIconId = mDataTypeIconId = 0;
+ mPhoneSignalIconId = mDataSignalIconId = mDataTypeIconId = mQSDataTypeIconId = 0;
mQSPhoneSignalIconId = 0;
// combined values from connected wifi take precedence over airplane mode
@@ -1125,12 +1138,15 @@
? mContentDescriptionDataType : mContentDescriptionWifi;
mDataTypeIconId = 0;
+ mQSDataTypeIconId = 0;
if (isCdma()) {
if (isCdmaEri()) {
mDataTypeIconId = R.drawable.stat_sys_data_connected_roam;
+ mQSDataTypeIconId = R.drawable.ic_qs_signal_r;
}
} else if (mPhone.isNetworkRoaming()) {
mDataTypeIconId = R.drawable.stat_sys_data_connected_roam;
+ mQSDataTypeIconId = R.drawable.ic_qs_signal_r;
}
}
@@ -1155,6 +1171,7 @@
+ " mDataDirectionIconId=0x" + Integer.toHexString(mDataDirectionIconId)
+ " mDataSignalIconId=0x" + Integer.toHexString(mDataSignalIconId)
+ " mDataTypeIconId=0x" + Integer.toHexString(mDataTypeIconId)
+ + " mQSDataTypeIconId=0x" + Integer.toHexString(mQSDataTypeIconId)
+ " mWifiIconId=0x" + Integer.toHexString(mWifiIconId)
+ " mQSWifiIconId=0x" + Integer.toHexString(mQSWifiIconId)
+ " mBluetoothTetherIconId=0x" + Integer.toHexString(mBluetoothTetherIconId));
@@ -1386,6 +1403,10 @@
pw.print(Integer.toHexString(mDataTypeIconId));
pw.print("/");
pw.println(getResourceName(mDataTypeIconId));
+ pw.print(" mQSDataTypeIconId=");
+ pw.print(Integer.toHexString(mQSDataTypeIconId));
+ pw.print("/");
+ pw.println(getResourceName(mQSDataTypeIconId));
pw.println(" - wifi ------");
pw.print(" mWifiEnabled=");