summaryrefslogtreecommitdiffstats
path: root/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java
diff options
context:
space:
mode:
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java')
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java185
1 files changed, 141 insertions, 44 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java b/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java
index 418c57f..8e50abe 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java
@@ -17,8 +17,10 @@
package com.android.systemui.statusbar;
import android.content.Context;
+import android.telephony.SubscriptionInfo;
import android.util.AttributeSet;
import android.util.Log;
+import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
@@ -29,6 +31,9 @@ import com.android.systemui.R;
import com.android.systemui.statusbar.policy.NetworkControllerImpl;
import com.android.systemui.statusbar.policy.SecurityController;
+import java.util.ArrayList;
+import java.util.List;
+
// Intimately tied to the design of res/layout/signal_cluster_view.xml
public class SignalClusterView
extends LinearLayout
@@ -41,23 +46,24 @@ public class SignalClusterView
NetworkControllerImpl mNC;
SecurityController mSC;
+ private boolean mNoSimsVisible = false;
private boolean mVpnVisible = false;
private boolean mWifiVisible = false;
private int mWifiStrengthId = 0;
- private boolean mMobileVisible = false;
- private int mMobileStrengthId = 0, mMobileTypeId = 0;
private boolean mIsAirplaneMode = false;
private int mAirplaneIconId = 0;
private int mAirplaneContentDescription;
- private String mWifiDescription, mMobileDescription, mMobileTypeDescription;
- private boolean mIsMobileTypeIconWide;
+ private String mWifiDescription;
+ private ArrayList<PhoneState> mPhoneStates = new ArrayList<PhoneState>();
- ViewGroup mWifiGroup, mMobileGroup;
- ImageView mVpn, mWifi, mMobile, mMobileType, mAirplane;
+ ViewGroup mWifiGroup;
+ ImageView mVpn, mWifi, mAirplane, mNoSims;
View mWifiAirplaneSpacer;
View mWifiSignalSpacer;
+ LinearLayout mMobileSignalGroup;
private int mWideTypeIconStartPadding;
+ private int mSecondaryTelephonyPadding;
private int mEndPadding;
private int mEndPaddingNothingVisible;
@@ -90,6 +96,8 @@ public class SignalClusterView
super.onFinishInflate();
mWideTypeIconStartPadding = getContext().getResources().getDimensionPixelSize(
R.dimen.wide_type_icon_start_padding);
+ mSecondaryTelephonyPadding = getContext().getResources().getDimensionPixelSize(
+ R.dimen.secondary_telephony_padding);
mEndPadding = getContext().getResources().getDimensionPixelSize(
R.dimen.signal_cluster_battery_padding);
mEndPaddingNothingVisible = getContext().getResources().getDimensionPixelSize(
@@ -103,12 +111,14 @@ public class SignalClusterView
mVpn = (ImageView) findViewById(R.id.vpn);
mWifiGroup = (ViewGroup) findViewById(R.id.wifi_combo);
mWifi = (ImageView) findViewById(R.id.wifi_signal);
- mMobileGroup = (ViewGroup) findViewById(R.id.mobile_combo);
- mMobile = (ImageView) findViewById(R.id.mobile_signal);
- mMobileType = (ImageView) findViewById(R.id.mobile_type);
mAirplane = (ImageView) findViewById(R.id.airplane);
+ mNoSims = (ImageView) findViewById(R.id.no_sims);
mWifiAirplaneSpacer = findViewById(R.id.wifi_airplane_spacer);
mWifiSignalSpacer = findViewById(R.id.wifi_signal_spacer);
+ mMobileSignalGroup = (LinearLayout) findViewById(R.id.mobile_signal_group);
+ for (PhoneState state : mPhoneStates) {
+ mMobileSignalGroup.addView(state.mMobileGroup);
+ }
apply();
}
@@ -118,10 +128,9 @@ public class SignalClusterView
mVpn = null;
mWifiGroup = null;
mWifi = null;
- mMobileGroup = null;
- mMobile = null;
- mMobileType = null;
mAirplane = null;
+ mMobileSignalGroup.removeAllViews();
+ mMobileSignalGroup = null;
super.onDetachedFromWindow();
}
@@ -149,18 +158,56 @@ public class SignalClusterView
@Override
public void setMobileDataIndicators(boolean visible, int strengthIcon, int typeIcon,
- String contentDescription, String typeContentDescription, boolean isTypeIconWide) {
- mMobileVisible = visible;
- mMobileStrengthId = strengthIcon;
- mMobileTypeId = typeIcon;
- mMobileDescription = contentDescription;
- mMobileTypeDescription = typeContentDescription;
- mIsMobileTypeIconWide = isTypeIconWide;
+ String contentDescription, String typeContentDescription, boolean isTypeIconWide,
+ int subId) {
+ PhoneState state = getOrInflateState(subId);
+ state.mMobileVisible = visible;
+ state.mMobileStrengthId = strengthIcon;
+ state.mMobileTypeId = typeIcon;
+ state.mMobileDescription = contentDescription;
+ state.mMobileTypeDescription = typeContentDescription;
+ state.mIsMobileTypeIconWide = isTypeIconWide;
apply();
}
@Override
+ public void setNoSims(boolean show) {
+ mNoSimsVisible = show;
+ }
+
+ @Override
+ public void setSubs(List<SubscriptionInfo> subs) {
+ // Clear out all old subIds.
+ mPhoneStates.clear();
+ if (mMobileSignalGroup != null) {
+ mMobileSignalGroup.removeAllViews();
+ }
+ final int n = subs.size();
+ for (int i = 0; i < n; i++) {
+ inflatePhoneState(subs.get(i).getSubscriptionId());
+ }
+ }
+
+ private PhoneState getOrInflateState(int subId) {
+ for (PhoneState state : mPhoneStates) {
+ if (state.mSubId == subId) {
+ return state;
+ }
+ }
+ return inflatePhoneState(subId);
+ }
+
+ private PhoneState inflatePhoneState(int subId) {
+ PhoneState state = new PhoneState(subId, mContext);
+ if (mMobileSignalGroup != null) {
+ mMobileSignalGroup.addView(state.mMobileGroup);
+ }
+ mPhoneStates.add(state);
+ return state;
+ }
+
+ @Override
public void setIsAirplaneMode(boolean is, int airplaneIconId, int contentDescription) {
mIsAirplaneMode = is;
mAirplaneIconId = airplaneIconId;
@@ -175,8 +222,9 @@ public class SignalClusterView
// ignore content description, so populate manually
if (mWifiVisible && mWifiGroup != null && mWifiGroup.getContentDescription() != null)
event.getText().add(mWifiGroup.getContentDescription());
- if (mMobileVisible && mMobileGroup != null && mMobileGroup.getContentDescription() != null)
- event.getText().add(mMobileGroup.getContentDescription());
+ for (PhoneState state : mPhoneStates) {
+ state.populateAccessibilityEvent(event);
+ }
return super.dispatchPopulateAccessibilityEvent(event);
}
@@ -188,12 +236,13 @@ public class SignalClusterView
mWifi.setImageDrawable(null);
}
- if (mMobile != null) {
- mMobile.setImageDrawable(null);
- }
-
- if (mMobileType != null) {
- mMobileType.setImageDrawable(null);
+ for (PhoneState state : mPhoneStates) {
+ if (state.mMobile != null) {
+ state.mMobile.setImageDrawable(null);
+ }
+ if (state.mMobileType != null) {
+ state.mMobileType.setImageDrawable(null);
+ }
}
if(mAirplane != null) {
@@ -227,19 +276,17 @@ public class SignalClusterView
(mWifiVisible ? "VISIBLE" : "GONE"),
mWifiStrengthId));
- if (mMobileVisible && !mIsAirplaneMode) {
- mMobile.setImageResource(mMobileStrengthId);
- mMobileType.setImageResource(mMobileTypeId);
- mMobileGroup.setContentDescription(mMobileTypeDescription + " " + mMobileDescription);
- mMobileGroup.setVisibility(View.VISIBLE);
- } else {
- mMobileGroup.setVisibility(View.GONE);
+ boolean anyMobileVisible = false;
+ for (PhoneState state : mPhoneStates) {
+ if (state.apply(anyMobileVisible)) {
+ anyMobileVisible = true;
+ }
}
if (mIsAirplaneMode) {
mAirplane.setImageResource(mAirplaneIconId);
mAirplane.setContentDescription(mAirplaneContentDescription != 0 ?
- mContext.getString(mAirplaneContentDescription) : "");
+ mContext.getString(mAirplaneContentDescription) : null);
mAirplane.setVisibility(View.VISIBLE);
} else {
mAirplane.setVisibility(View.GONE);
@@ -251,23 +298,73 @@ public class SignalClusterView
mWifiAirplaneSpacer.setVisibility(View.GONE);
}
- if (mMobileVisible && mMobileTypeId != 0 && mWifiVisible) {
+ if ((anyMobileVisible || mNoSimsVisible) && mWifiVisible) {
mWifiSignalSpacer.setVisibility(View.VISIBLE);
} else {
mWifiSignalSpacer.setVisibility(View.GONE);
}
- mMobile.setPaddingRelative(mIsMobileTypeIconWide ? mWideTypeIconStartPadding : 0, 0, 0, 0);
+ mNoSims.setVisibility(mNoSimsVisible ? View.VISIBLE : View.GONE);
- if (DEBUG) Log.d(TAG,
- String.format("mobile: %s sig=%d typ=%d",
- (mMobileVisible ? "VISIBLE" : "GONE"),
- mMobileStrengthId, mMobileTypeId));
+ boolean anythingVisible = mNoSimsVisible || mWifiVisible || mIsAirplaneMode
+ || anyMobileVisible || mVpnVisible;
+ setPaddingRelative(0, 0, anythingVisible ? mEndPadding : mEndPaddingNothingVisible, 0);
+ }
- mMobileType.setVisibility(mMobileTypeId != 0 ? View.VISIBLE : View.GONE);
+ private class PhoneState {
+ private final int mSubId;
+ private boolean mMobileVisible = false;
+ private int mMobileStrengthId = 0, mMobileTypeId = 0;
+ private boolean mIsMobileTypeIconWide;
+ private String mMobileDescription, mMobileTypeDescription;
+
+ private ViewGroup mMobileGroup;
+ private ImageView mMobile, mMobileType;
+
+ public PhoneState(int subId, Context context) {
+ ViewGroup root = (ViewGroup) LayoutInflater.from(context)
+ .inflate(R.layout.mobile_signal_group, null);
+ setViews(root);
+ mSubId = subId;
+ }
- boolean anythingVisible = mWifiVisible || mIsAirplaneMode || mMobileVisible || mVpnVisible;
- setPaddingRelative(0, 0, anythingVisible ? mEndPadding : mEndPaddingNothingVisible, 0);
+ public void setViews(ViewGroup root) {
+ mMobileGroup = root;
+ mMobile = (ImageView) root.findViewById(R.id.mobile_signal);
+ mMobileType = (ImageView) root.findViewById(R.id.mobile_type);
+ }
+
+ public boolean apply(boolean isSecondaryIcon) {
+ if (mMobileVisible && !mIsAirplaneMode) {
+ mMobile.setImageResource(mMobileStrengthId);
+ mMobileType.setImageResource(mMobileTypeId);
+ mMobileGroup.setContentDescription(mMobileTypeDescription
+ + " " + mMobileDescription);
+ mMobileGroup.setVisibility(View.VISIBLE);
+ } else {
+ mMobileGroup.setVisibility(View.GONE);
+ }
+
+ // When this isn't next to wifi, give it some extra padding between the signals.
+ mMobileGroup.setPaddingRelative(isSecondaryIcon ? mSecondaryTelephonyPadding : 0,
+ 0, 0, 0);
+ mMobile.setPaddingRelative(mIsMobileTypeIconWide ? mWideTypeIconStartPadding : 0,
+ 0, 0, 0);
+
+ if (DEBUG) Log.d(TAG, String.format("mobile: %s sig=%d typ=%d",
+ (mMobileVisible ? "VISIBLE" : "GONE"), mMobileStrengthId, mMobileTypeId));
+
+ mMobileType.setVisibility(mMobileTypeId != 0 ? View.VISIBLE : View.GONE);
+
+ return mMobileVisible;
+ }
+
+ public void populateAccessibilityEvent(AccessibilityEvent event) {
+ if (mMobileVisible && mMobileGroup != null
+ && mMobileGroup.getContentDescription() != null) {
+ event.getText().add(mMobileGroup.getContentDescription());
+ }
+ }
}
}